GB_001 Posted April 9, 2008 Share Posted April 9, 2008 Hello I was wondering how I would go about updating a div's html content with DOM? Quote Link to comment Share on other sites More sharing options...
GB_001 Posted April 9, 2008 Author Share Posted April 9, 2008 Okay, it to partially work. The text appears but the html does not appear. <html> <head> <script language="javascript" type="text/javascript"> function go(){ document.getElementById('wow').innerHTML = <html><head></head> <body bgcolor="black"> RAWR</body></html>; }</script> </head> <body> <div id='wow'><input type='button' onClick="go();" value="BAM"> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
jacksonmj Posted April 9, 2008 Share Posted April 9, 2008 innerHTML refers to the contents of an element, not a whole html page. You would not do <div id='wow'><html><head></head> <body bgcolor="black"> RAWR</body></html></div> but instead just <div id='wow'>RAWR</div> Use something like document.getElementById('wow').innerHTML = 'RAWR'; document.getElementById('wow').style.backgroundColor = 'green'; inside the go() function. Quote Link to comment Share on other sites More sharing options...
GB_001 Posted April 9, 2008 Author Share Posted April 9, 2008 Thankyou. =). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.