• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 761
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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