Rachit Shah Posted March 23, 2006 Share Posted March 23, 2006 I need some insight regarding below code.In the below code...If I change <\/script> to </script> its giving error.If I change <\/head> to </head> its not giving error. Why? Why? Why?Here is the working code. Its working fine. The above scenario is visible here. I have put it in red. <html><head><script id='script1' name='script1' type="text/javascript">function writeIt () {var x="";x = x + "<html>\n<head>\n";x= x + "<script>" + window.document.scripts(0).text;x = x + "<\/script>\n";x = x + "</head>\n<body>\n";x = x + document.body.innerHTML;x = x + "\n</body>\n</html>";alert(x);document.close(); // or document.open();document.write(x);}</script></head><body><input type="button" onclick="writeIt()" value="Write"/>rachit</body></html>Is this thing Browser specific? I mean Implementation specific? Link to comment Share on other sites More sharing options...
Webworldx Posted March 23, 2006 Share Posted March 23, 2006 Basically, if javascript runs across </script>, it'll count it as the end of the script. If it runs across </head>, it won't, as it's not a javascript tag Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now