I am a beginner in Java script programming. Although I have done a lot of program in HTML. I wrote my first JavaScript program in note pad and saved as first.js in note pad and opened the program in internet explorer.
I got an error as compilation error in line 1, char 1, syntax error, code -800A03EA and I have searched in google but unable to resolve this issue. Can anyone help me to go through this. My program is
I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
rename the file to first.html - html files should not have the .js extension - make sure you have the complete filename visible in Windows Explorer - this is done by unchecking the “Hide extensions for known file types” option in Folder Options:View
IE gives the error because it tries the run the entire file as a jscript file - which it is not
hopefully you got the page to load after renaming the file - here’s a few tips on your html so far
always start your html file with the doctype declaration - it should be the very first thing on the very first line of the file
<!doctype html>
<html>
</html>
Any text content that you want shown on the web page must be somewhere inside the <body> element - don’t put any text for display in the <head> element - browsers will still show the misplaced text after moving it to inside <body>
the <head> element is not a heading for the page - use the <h1> tag inside <body> like this
<body>
<h1>Somu</h1>
</body>
there was a time when the type attribute for <script> had some use - that time is no longer - just use the following for javascript
Thanks ppc.
I got that it will run if i will change the extension name to html.But can you please tell me what should be program code for the same in javascript ?
If you’re asking what should be the filename for javascript the answer is the filename can be anything - typically it should have the .js extension but it’s not required - the filename is referenced in the html with the src attribute of an empty <script> tag