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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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)
Ys
BTW nabsol:
But your code doesn't work for Opera 6.x :P
But your code doesn't work for Opera 6.x :P
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("m
(nabsol uses this syntax as you can see though)