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? Link to comment https://forums.phpfreaks.com/topic/100249-update-a-divs-content-with-dom/ 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> Link to comment https://forums.phpfreaks.com/topic/100249-update-a-divs-content-with-dom/#findComment-512601 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. Link to comment https://forums.phpfreaks.com/topic/100249-update-a-divs-content-with-dom/#findComment-513309 Share on other sites More sharing options...
GB_001 Posted April 9, 2008 Author Share Posted April 9, 2008 Thankyou. =). Link to comment https://forums.phpfreaks.com/topic/100249-update-a-divs-content-with-dom/#findComment-513318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.