cmattoon Posted May 17, 2011 Share Posted May 17, 2011 I borrowed a free script to make a basic news scroller with the use of an XML file. Basically, it loads the XML file, then does: document.all.write('<div id="news_panel"></div>'); Later on in the script, it does: document.all.getElementById(news_panel).innerHTML = '.......'; Up until recently, this has worked fine because it was on a test page by itself. However, when I integrate into the existing main page, I can't seem to put it where I want it. When I code the DIV as HTML, it doesn't want to write into that DIV using the 2nd line of code (above). It only seems to write when the DIV is written through the document.all.write() method. The other thing I tried was to code (in HTML) a <div id="mainNewsFrame"></div> and then write the news_panel DIV into the mainNewsFrame DIV, but that doesn't work either. I'm not sure what the document.ALL.getElementById() means either.. in previous JavaScript code I've seen, it's simply "document.write" or "document.getElementById()".. any idea what the "all" is for? (If you can't tell, I'm not very familiar with JavaScript!) Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/236671-innerhtml-question/ Share on other sites More sharing options...
markjoe Posted May 17, 2011 Share Posted May 17, 2011 My guess is that free script is ancient garbage. Don't use document.write(). I haven't seen document.all.* used in so long I don't even remember what it does anymore. if your html contains <div id="news_panel"></div>, then document.getElementById('news_panel').innerHTML = '......' should work just fine. if you need to add html elements to the document at runtime, either set or append it to document.body.innerHTML or create the DOM element with document.createElement('div') and then use appendChild() on what ever parent element you want to append it to. Quote Link to comment https://forums.phpfreaks.com/topic/236671-innerhtml-question/#findComment-1216644 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.