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?
HometownCompAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nabsolCommented:
Hi
I think you want HTML of entire page. Check out this code works for both ie6 and firefox. :)

<html id="myhtml">
<script language="JavaScript">
function test()
{
  alert(document.getElementById("myhtml").innerHTML)
}
</script>

<body id="mybody" onload="test()">
<div id="mydiv">
abcdabcd
</div>
</body>
</html>

By Nab

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smaccariCommented:
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)
ysreCommented:
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
ysreCommented:
BTW nabsol:
But your code doesn't work for Opera 6.x :P
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.