var xmlhttp = null;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
return xmlhttp.responceText;
}
}
this.model.result = xmlhttp.onreadystatechange;
xmlhttp.open("GET", this.model.konfig, false);
xmlhttp.send();
}
how can I get the content of a Web page as a string so I can print it somwhere else using javascript
Asked
Active
Viewed 68 times
0

Niet the Dark Absol
- 320,036
- 81
- 464
- 592
-
If you wish to load external page via link and read it as string, refer http://stackoverflow.com/questions/14779467/html-source-code-of-external-webpage-as-string – Rajesh Jun 22 '16 at 10:22
-
@Rajesh, not even remotely close. – Oleg V. Volkov Jun 22 '16 at 10:23
-
And if you just wish to open some page in some div of your page, you can look into `iFrames`. – Rajesh Jun 22 '16 at 10:24
1 Answers
0
You can obtain the HTML content of any node with innerHTML
.
Example (for body
node):
document.getElementsByTagName('body')[0].innerHTML

José M. Carnero
- 263
- 1
- 8