JavaScript How To file:///C:/Users/julian/AppData/Roaming/Mozilla/Firefox/Profiles/vwqzts... JS Basic JS HOME JavaScript How To JS Introduction JS How To « Previous Next Chapter » JS Where To JS Statements JS Comments The HTML <script> tag is used to insert a JavaScript into an HTML page. JS Variables JS Operators JS Comparisons Put a JavaScript into an HTML page JS If...Else JS Switch The example below shows how to use JavaScript to write text on a web page: JS Popup Boxes JS Functions JS For Loop Example JS While Loop JS Break Loops <html> JS For...In <body> JS Events <script type="text/javascript"> JS Try...Catch document.write("Hello World!"); JS Throw </script> JS Special Text </body> JS Guidelines </html> JS Objects Try it yourself » JS Objects Intro JS String JS Date The example below shows how to add HTML tags to the JavaScript: JS Array JS Boolean JS Math Example JS RegExp <html> <body> JS Advanced <script type="text/javascript"> JS Browser document.write("<h1>Hello World!</h1>"); JS Cookies </script> JS Validation </body> JS Animation </html> JS Image Maps JS Timing JS Create Object Try it yourself » JS Summary JS Examples JS Examples Example Explained JS Objects Examples JS Browser Examples To insert a JavaScript into an HTML page, we use the <script> tag. Inside the <script> tag we JS HTML DOM Examples use the type attribute to define the scripting language. JS Quiz JS Exam So, the <script type="text/javascript"> and </script> tells where the JavaScript starts and ends: JS References <html> JavaScript Objects <body> HTML DOM Objects <script type="text/javascript"> ... </script> </body> </html> The document.write command is a standard JavaScript command for writing output to a page. By entering the document.write command between the <script> and </script> tags, the browser will recognize it as a JavaScript command and execute the code line. In this case the browser will write Hello World! to the page: <html> <body> <script type="text/javascript"> document.write("Hello World!"); </script> </body> </html> Note: If we had not entered the <script> tag, the browser would have treated the document.write("Hello World!") command as pure text, and just write the entire line on the page. Try it yourself How to Handle Simple Browsers Browsers that do not support JavaScript, will display JavaScript as page content. To prevent them from doing this, and as a part of the JavaScript standard, the HTML comment tag should be used to "hide" the JavaScript. Just add an HTML comment tag <!-- before the first JavaScript statement, and a --> (end of 1 de 1 29/05/2010 10:44 p.m.

Java script how to

  • 1.
    JavaScript How To file:///C:/Users/julian/AppData/Roaming/Mozilla/Firefox/Profiles/vwqzts... JS Basic JS HOME JavaScript How To JS Introduction JS How To « Previous Next Chapter » JS Where To JS Statements JS Comments The HTML <script> tag is used to insert a JavaScript into an HTML page. JS Variables JS Operators JS Comparisons Put a JavaScript into an HTML page JS If...Else JS Switch The example below shows how to use JavaScript to write text on a web page: JS Popup Boxes JS Functions JS For Loop Example JS While Loop JS Break Loops <html> JS For...In <body> JS Events <script type="text/javascript"> JS Try...Catch document.write("Hello World!"); JS Throw </script> JS Special Text </body> JS Guidelines </html> JS Objects Try it yourself » JS Objects Intro JS String JS Date The example below shows how to add HTML tags to the JavaScript: JS Array JS Boolean JS Math Example JS RegExp <html> <body> JS Advanced <script type="text/javascript"> JS Browser document.write("<h1>Hello World!</h1>"); JS Cookies </script> JS Validation </body> JS Animation </html> JS Image Maps JS Timing JS Create Object Try it yourself » JS Summary JS Examples JS Examples Example Explained JS Objects Examples JS Browser Examples To insert a JavaScript into an HTML page, we use the <script> tag. Inside the <script> tag we JS HTML DOM Examples use the type attribute to define the scripting language. JS Quiz JS Exam So, the <script type="text/javascript"> and </script> tells where the JavaScript starts and ends: JS References <html> JavaScript Objects <body> HTML DOM Objects <script type="text/javascript"> ... </script> </body> </html> The document.write command is a standard JavaScript command for writing output to a page. By entering the document.write command between the <script> and </script> tags, the browser will recognize it as a JavaScript command and execute the code line. In this case the browser will write Hello World! to the page: <html> <body> <script type="text/javascript"> document.write("Hello World!"); </script> </body> </html> Note: If we had not entered the <script> tag, the browser would have treated the document.write("Hello World!") command as pure text, and just write the entire line on the page. Try it yourself How to Handle Simple Browsers Browsers that do not support JavaScript, will display JavaScript as page content. To prevent them from doing this, and as a part of the JavaScript standard, the HTML comment tag should be used to "hide" the JavaScript. Just add an HTML comment tag <!-- before the first JavaScript statement, and a --> (end of 1 de 1 29/05/2010 10:44 p.m.