Link to home
Start Free TrialLog in
Avatar of HometownComp
HometownComp

asked on

innerHTML solution for FireFox

In the IE6 I can use Javascript to get the innerHTML   ie       "something".innerHTML

But in Firefox nothing is returned.  What javascript will return the innerHTML or the HTML of the entire page for Firefox please?
ASKER CERTIFIED SOLUTION
Avatar of nabsol
nabsol
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smaccari
smaccari

There is something weird in your title and question, as Firefox does implement the innerHTML property, and it works fine.
Maybe that's because by "something".innerHTML, you mean that if you have an element with id "mydiv", you try to acces its innerHTML by: myDiv.innerHTML
Maybe You should use: document.getElementById("myDiv").innerHTML
(nabsol uses this syntax as you can see though)
According to the DOM model (and eg. firefox keeps complaining vigorously ?? if you don't ;)) you have to get every element via document.getElementBy* (eg. var el = document.getElementById ("myelementid"); if (el) { /* do sth with the element */ } ).

Then you'd just use  el.innerHTML = mynewhtmlforelement;

In case of some mozilla-like browsers not providing the .innerHTML property  get mozInnerHTML.js (google) and add it if you can't find the .innerHTML property, eg. if (!document.body.innerHTML) { document.write ("<SCRI"+"PT language='JavaScript' src='./mozInnerHTML.js'></S"+"CRIPT>"); }

Ys
BTW nabsol:
But your code doesn't work for Opera 6.x :P