Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm new at programming. I've done the HTML, CSS, website build and JAVASCRIPT courses on Codecademy. I've done some of the Eloquent Javascript and got a little lost in the sauce around chapter 5. I saw someone advise on here to take the JavascriptIsSexy route which I've been doing. I downloaded Notepad++ and have started going through "Beginning Javascript" book that is used in that "study guide". My problem is I cannot get anything, and I mean anything to run in a browser. IE, Firefox or Chrome. Even the simplest of things produce no output. The page loads either blank, or shows the first line of HTML and no more. Any blocks, functions and the like never run. White page. 1 or no lines. I've looked around for anyone having similar issues and haven't found it. Which makes me pretty sure I'm the problem here. I'd offer samples of code, but anything you can write in 60 would suffice as a good example. I am saving the files in a designated folder with the correct file types (.html or .js), closing all tags, etc.
Not exactly sure how to continue. I can't keep "practicing" if i cant get anything to run. I've tried using the RUN button in Notepad++ and selecting a browser. I've also tried opening a browser, choosing OPEN and selecting one of the files. I've even directly copied and pasted code right out of the book and tried to run it that way to make sure it isn't just a bug on my part. Same result.
I also tried writing and playing with codes in the "console" of IE and Chrome, but I can't get either of them to respond as I have no idea how to use them.
If this is a really dumb question or I haven't given you enough info to try and help me out, I apologize. I would appreciate any help you guys could throw out there.
Thanks.
First of all, you guys are awesome. I thought I'd be waiting for a couple days for some help. Seriously, that's cool. Here's a bit of code, one of the first examples the book has you run in a browser.
<html>
<body bgColor = "WHITE">
<p>Paragraph 1</p>
<script type="text/javascript">
alert("First Script Block");
</script7>
<p>Paragraph 2</p>
<script type="text/javascript">
document.bgColor ="RED";
alert("Second Script Block");
</script7>
<p>Paragraph 3</p>
</body>
</html>
Like I said. Very simple... I get nothing. Thanks again for the quick responses. You guys rock.
Open a new file in Notepad++ and add:
<!DOCTYPE HTML>
<html>
<body>
<script>
alert('This Should be a Popup Alert')
</script>
</body>
</html>
Save as test.html, make sure to save as "All Files".
Right click on the file, and open with any browser and should run in the browser just fine. Now just adapt the javascript you want to play with.
Not a dumb question at all. This is one of the most common things to try and get used to when you're starting out. So I'll ask you a question because this is the most common thing that newcomers forget - did you load all you files in to your index.html (or whatever your html file is name) file? If you're not sure, go to your website or page, and view source. Do a search for '.css'. If you can't find anything, you haven't loaded any stylesheets. Next do a search for 'script'. If you can't find that, you didn't include any javascript files. Is your site live? You need to FTP to it and upload the files to the server also. Here's a resource for importing your stylesheets and scripts into the DOM. http://webcomponents.org/articles/introduction-to-html-imports/ If you need help with FTP, let me know, I'd be glad to help, as I wish someone would have helped me when I was starting out.
If you are using console.log() to produce output, you won't see it in the browser's window that normally displays HTML. You need to look at the console. On Chrome it can be reached via the menu at View > Developer > Developer Tools.
Can you paste a code snippet in one of your index.html pages, you should try to learn and use xammp.
Install xammp
Once installed click the button "Start" on Apache
Move the project / website your doing into the following directory, make a folder name for it e.g. TestOne C:\xampp\htdocs
open Google Chrome or IE and put the following in the URL
localhost/TestOne/index.html
or whatever your index file of the website your making index.php etc..
You may need to run it on a server. You can make a local sever with tomcat. I hope this commit helps. You can always use a online website to emulate running it on your machine.
thanks,
adbadb25
When you are first learning how to code, I would start with a basic html format. Html,head, closing head,body, closing body,closing html. Inside the body tags, start with something simple. Opening and closing paragraphs tags. "Hello World".
Related
I've been working on this website on my computer for the past several weeks, but have had it a point that I just can't figure something out with my table sorting. The site itself runs off PHP but I've duplicated the HTML output to make it easier for you guys to help me diagnose what the problem is.
Here's a link to the Working Page: http://privateservercloud.com/working.htm
Here's a link to the Not Working Page: http://privateservercloud.com/not-working.htm
If you go to the Working Page, you'll see that you can click on any of the headers of the table and it will sort them. However, if you go to the Not Working Page, you'll see that this doesn't happen.
I'm trying to figure out what's missing or coded incorrectly and causing this to happen. I've uploaded all of the HTML, CSS, and Javascript that's running this part of the site so you can see how it's all working and hopefully that'll make life a bit easier for anyone that can help.
So... does anyone see what I'm doing wrong or know what needs to be fixed?
I load the not-working example in Firefox with Firebug and get the following:
TypeError: document.getElementById(...) is null
...for(var e=0;e<menuids.length;e++){var t=document.getElementById(menuids[e]).getE...
in dropdown.js line 1.
The debugging tools really are your friends. If you don't want to use Firefox, you can do the same thing with the development tools in Chrome.
I find errors when I run rhe validator at http://validator.w3.org and a pile of CSS errors at http://jigsaw.w3.org/css-validator/
When things don't work right, validate the HTML, which at least mostly assures you have a valid DOM. Then validate the CSS and use the JavaScript console in your favorite browser's debugger.
So I am just starting out trying to familiarize myself with some HTML, and for lack of knowledge of better places to start, I have been looking at some source code taken from websites and copy and pasting them into a notepad and then running the html file. But when I do this I often get incomplete pages with no links working(for example stackoverflow website). Is this because I don't have the images saved on my website, or because there are CSS and javascript pages that are hidden, or what other reason?
Why do simpler webpages (say http://sheldonbrown.com/web_sample1.html) look mostly complete when i do this, but more complicated/bigger websites have this problem?
Also if anyone has a good alternative to learning HTML that would also be appreciated.
Thanks
Just to add onto this question, is there something wrong with writing html in a notepad? I noticed that even if i have a text file that says "hello" and nothing else, running it as a html file will show hello, should this happen? Also, it seems to ignore my conditional statements say I do
i am not ie
the "i am not ie" message still appears in all browsers (IE included). Why is this the case as well?
Say I have a very tiny webpage, http://www.my-tiny-page.com:
<html>
<body>
<img src="/images/example.jpg" >
</body>
</html>
You look at the source, simple enough, and copy it to your notepad, and open it.
HEY! The image is not loading?!
The reason for this is really simple actually. The tiny-website links to the image relatively, which means they don't add the full domainname to it (= a lot easier).
Relative means "look from the directory where I am", or when starting with a slash it means "look from the extention (also know as document root)".
If you change the images to the full url, it'll work again:
http://www.my-tiny-page.com/images/example.jpg
How about styling and javascript? Exact same principle.
The reason it's not working is because the HTML only contains the basic structure and content of the site. Images are almost always linked relative to the root directory, meaning your browser is not going to be able to find them unless you saved the images in the same folder structure as the website. Without the CSS files(styling), Javascript files(functionality), images, etc. it's not going to look anything like the page where you're getting the code from.
Also, chances are the code you are seeing could have been generated by PHP, either way, it's probably too advanced for someone just starting out.
My suggestion would be to take an online course, there are several beginner HTML/CSS courses available. I was a big fan of Code School when I first started out.
Learn the basics of HTML first(html/body tags, headers, divs, etc.) before moving on to more advanced stuff.
To address your additional question:
No. There is nothing wrong with using notepad to write HTML, in fact, back in 2004 when I first started, that is exactly what I used. However, we have come a long way since then. There are now text editors that can predict what you are trying to do as well as color code your tags to make it easier to debug. While there's nothing wrong with using Notepad, I would STRONGLY suggest using something like Sublime Text instead, it will make your life much easier.
Here is what a proper conditional statement to target only IE would look like:
<!--[if IE]>
Only IE browsers can see this.
<![endif]-->
You can also target specific versions of IE. That would look like this:
<!--[if lt IE 8]>
Only IE7 or lower browsers can see this.
<![endif]-->
In the above conditional statement you are saying, if the browser is less than(lt) IE 8, then display this.
How do I save or convert the HTML code into its own program? For example: I want to double click on the file on my desktop to open up as its own application. I don't want it to open through Notepad++ or any other program.
The best way I can explain this is: look at all of your desktop icons. When you double click something it runs on its own. It doesn't need Notepad++ or whatever coding program you used to open up first. Now implementing that exact same concept to my question. I want to open the program I have coded in it's own window.
I hope that makes sense. I don't want to show my code because it's original.
EDIT: The HTML code consists of CSS and JS. Can I open it without a browser? Example: Visual Basics you can create window applications. I was wondering if I could do the same thing except with HTML code?
Thank you in advance!
You right click on the icon, and choose Open With: which should bring up a list of applications you can use to open that type of file.
And you can browse to the location of the program you want to use to open the file.
Hope that helps.
HTML is not compiled into anything, and thus cannot be run independently. It must be interpreted by a browser or other similar piece of software.
If you have written what you deem a 'program' in HTML/JavaScript, then your best bet would be to host it somewhere and bookmark the page to your desktop. I hope this answers your question...
I am new to javascript and have been working overnight to see how I can fix this error on IE: Here's the question I asked here yesterday: How to fix this jquery function to work in IE?
After spending more than 20 hours I still can't find out why it wouldn't render parts of my page properly.
At the very least I thought I could find a way to get the errors so I can fix them or do a separate javascript file just for IE, but no luck.
How do I see error messages for my script?
I used F12 to see the developer console but no help there, it won't even tell me what's wrong.
I am using IE 8 and 9.
I know that there could be many things wrong with this and I appreciate your patience in advance for helping me out. Thanks!
You have invalid HTML including many invisible characters within the head section which is also blocking the W3C HTML Validator from getting past the first few errors.
When I copied your source code into my text editor, I found a bunch of invalid invisible characters. Did you cut/paste your JavaScript from someplace like a web-page? The invisibles only appear in front of your custom written scripts in the <head> and nowhere else. This could certainly explain a lot, including the validation error about a misplaced </head> tag. Go back to your editor and delete the indentations on every single line within the entire <head></head> section, then re-indent each line from scratch.
I also see an invalid closing tag, </label6>.
Remove the invisible characters, fix the invalid HTML, and see what IE does.
Moving forward, get yourself a powerful text editor that will allow you to see invisible characters so you can delete them and properly indent as needed. Otherwise, I recommend re-typing your code rather than cutting & pasting.
For JavaScript errors, the best is to see the 'Console' tab for records.
If IE's one isn't showing anything, maybe you could try using FireBug Lite, adding the following script after <head> (YES, put it as first thing, so it loads first than anything else).
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
On side note, maybe isn't a JS problem and yes something about running code locally. IE has some policies that mostly block client-side code from running. (Remember those annoying ActiveX prompts?). Check Intranet configuration on Settings.
Having problems in IE7.It does not show me the "mouse over- drop down".
This "mouse over" was working well till yesterday also works in FireFox.
There a table that displays all the current documents.When one does a mouse over on a given document,it displays a list of options in form of a dropdown.
Can it be corrected in IE settings etc?
I am not talking about the javascript here , only the user settings.I am strictly the end user in this case.Also i tried downloading IE8 and it stopped in between.Hence I checked the ActiveX settings in IE and it was enabled.
Kindly help.
Your question seems well-founded, but it's difficult to discern what the question is exactly. Could you please elaborate? Source code may also help.
If you'd like to go a more DIY route, try throwing your code at JSLint. It will magically surface errors you didn't see.
Sitecore generates a lot of temporary and debug code files. This could be the problem. I would try deleting all of the temp/debug files, and see if that helps. They are scattered throughout the site, so you have to hunt for the debug directories.
However, I do see a lot of WEIRD JavaScript things with SiteCore. Sometimes I will load the content editor, and it wont work because of JS errors. I clear my cache and refresh and it works fine. But nothing in the JavaScript should be changing, since it would be the scripts from the vendor. I don't go in and change JS. Maybe they are generating JS somewhere.