"Get source" function

D

David Cohen

Is there a function that returns the html source of a given page as a
string?

Preferably, I'm looking for a function that takes a URL as an argument.
Alternatively, is there such a function that takes a handle to a
window (in which the desired page is open) as an argument?

Thank you,
David
 
E

Evertjan.

David Cohen wrote on 11 jul 2003 in comp.lang.javascript:
Is there a function that returns the html source of a given page as a
string?

Preferably, I'm looking for a function that takes a URL as an argument.



function getUrl(url) {
var http = new ActiveXObject("microsoft.xmlhttp");
http.open("GET",url,false);
http.send();
return http.responseText;
}
 
D

David Cohen

When I try this, I get a "permission denied" error on the http.open()
for every URL that I try.

--David
 
G

Grant Wagner

David said:
When I try this, I get a "permission denied" error on the http.open()
for every URL that I try.

--David

You won't be able to get the source of a page other then one in the same
domain that your script was downloaded from in the default security
environment.

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top