Entry
Can you acquire the source code of a page and put it into a string variable?
Aug 15th, 2001 07:43
Joe Lipman, Keith G,
I spent ages on this and nobody's got back so far on how to do this
with WWW pages. It is however possible to do this with an HTML page
already saved to disk.
I open the page to scan in another temporary window (to avoid any other
elements) and then close it once its scanned.
Try:
newWindow = window.open("","newUn");
var myString = newWindow.document.documentElement.innerHTML.value;
newWindow.close();
I've only tested this in MSIE. The above may be restricted to versions
5 and above. Otherwise try
var myString = newWindow.document.body.innerHTML.value;
You could replace innerHTML with outerHTML. Some say it makes a
massive difference. innerText and outerText work as well