Jump to content

Does JS need HTML to run?


Saeed

Recommended Posts

Did you try it? :)The W3C requires browsers to be VERY flexible and forgiving. They should try to render documents with no HTML or incorrect HTML as best they can. As long as you have <script> tags, code written between them should execute.

Link to comment
Share on other sites

You can also execute JavaScript in the URL of any page. The code will run as if it's part of the current page.For example, type the following in your browser:

java script:alert('There are '+document.getElementsByTagName('div').length+' "div" elements on this page.');

(NOTE: Remove the space between "java" and "script". The forum adds it for security reasons)As long as the code is one statement (possibly with closures... long story), you can do that.You can also open your browser's console and type there. On IE, press F12. Same on FF, but if you have Firebug installed.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...