Friday 15 February 2013

javascript - Writing to the DOM on body onload not working in Google Chrome -


Google क्रोम में, निम्न कोड स्निपेट:

  & lt; html xmlns = "http : //www.w3.org/1999/xhtml "& gt; & Lt; शीर्ष & gt; & Lt; title & gt; उदाहरण & lt; / title & gt; & Lt; स्क्रिप्ट प्रकार = "टेक्स्ट / जावास्क्रिप्ट" & gt; & Lt;! - फ़ंक्शन onBodyLoad () {var x = 42; Document.writeln ("x =" + x); चेतावनी ("लोड" पर); } - & gt; & Lt; / स्क्रिप्ट & gt; & Lt; / head & gt; & Lt; body onload = "onBodyLoad ()" & gt; & lt; / body & gt; & Lt; / html & gt; दस्तावेज़ में  

लिख नहीं है

x = 42

चेतावनी हालांकि प्रदर्शित किया जाता है। पाठ और चेतावनी दोनों IE8 और FF 3.5 में प्रदर्शित किए जाते हैं। किसी भी विचार?

आपको एक दस्तावेज़.क्लोज () करना होगा document.writeln () :

  फ़ंक्शन onBodyLoad () {var x = 42; Document.writeln ("x =" + x); चेतावनी ("लोड" पर); document.close (); }  

देखिए: साथ ही।


No comments:

Post a Comment