View Full Version : how do I view inner.HTML?
rptodd1
11-16-2006, 03:10 AM
I know I can alert it, but I want to be able to copy what my DOM script is producing and tweak it in an html editor. How can I output it to produce source I can copy? make that element.innerHTML
brandonH
11-16-2006, 05:52 AM
welll.... you can create a page that opens the page you want ina child window. then in the first window have a textarea and a button that when clicked grabs all the innerHTML of the child window and throws it into the textarea. you could even throw a <input type=file> in the first page so you can browse to the page you want to open.
brandonH
11-16-2006, 06:08 AM
I threw it together for you....
the below allows you to browse for the file you want to open in a new window, opens it in a new window, then grabs the outerHTML of the <html> tag and throws it into the textarea. it does not work on websites.... it will tell you access is denied. if you save the below as a .hta file though.... it'll work (IE only) :-)
<html><head><title>DOM HTML Viewer</title></head>
<body>
<input type=file id=file>
<input type=button value="open file in window" onclick="OpWin();">
<input type=button value="get HTML" onclick="getHTM();"><br>
<textarea id=textarea rows=20 cols=80></textarea>
</body>
<script type=text/javascript>
var myWin;
function OpWin(){
var loc=document.getElementById('file').value;
myWin=window.open(loc,'childWin');
}
function getHTM(){
document.getElementById('textarea').value=myWin.document.getElementsByTagName("html")[0].outerHTML;}
</script>
</html>
hope this is helpful.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.