Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 744
  • Last Modified:

Inner HTML in Firefox

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

But in Firefox nothing is returned.  What javascript will return the innerHTML or the HTML of the entire page please?
0
HometownComp
Asked:
HometownComp
2 Solutions
 
Cyber-DrugsCommented:
I think this is what you were after:

IE method to switch to source view:

iHTML = getDocument().body.innerHTML;
getDocument().body.innerText = iHTML;

Mozilla method to switch to source view:

var html = document.createTextNode(getDocument().body.innerHTML);
getDocument().body.innerHTML = "";
getDocument().body.appendChild(html);

IE method to switch back to regular view:

iText = getDocument().body.innerText;
getDocument().body.innerHTML = iText;

Mozilla method to switch back to regular view:

var html = getDocument().body.ownerDocument.createRange();
html.selectNodeContents(getDocument().body);
getDocument().body.innerHTML = html.toString();



All of which can be found here:
http://www.mozilla.org/editor/ie2midas.html
0
 
sergsokolenkoCommented:
This will work fine in both IE and Firefox.
var bodyElement = document.getElementsByTagName('html')[0].innerHTML;

Use document.getElementsByTagName('tag name') or document.getElementById('elements id') to access DOM element correctly.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now