"Get source" function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Cohen

    "Get source" function

    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

  • Evertjan.

    #2
    Re: "Get source" function

    David Cohen wrote on 11 jul 2003 in comp.lang.javas cript:[color=blue]
    > 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.[/color]



    function getUrl(url) {
    var http = new ActiveXObject(" microsoft.xmlht tp");
    http.open("GET" ,url,false);
    http.send();
    return http.responseTe xt;
    }


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • David Cohen

      #3
      Re: "Get source" function

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

      --David

      Evertjan. wrote:
      [color=blue]
      > function getUrl(url) {
      > var http = new ActiveXObject(" microsoft.xmlht tp");
      > http.open("GET" ,url,false);
      > http.send();
      > return http.responseTe xt;
      > }[/color]

      Comment

      • Grant Wagner

        #4
        Re: "Get source" function

        David Cohen wrote:
        [color=blue]
        > When I try this, I get a "permission denied" error on the http.open()
        > for every URL that I try.
        >
        > --David
        >
        > Evertjan. wrote:
        >[color=green]
        > > function getUrl(url) {
        > > var http = new ActiveXObject(" microsoft.xmlht tp");
        > > http.open("GET" ,url,false);
        > > http.send();
        > > return http.responseTe xt;
        > > }[/color][/color]

        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 <gwagner@agrico reunited.com>

        * Client-side Javascript and Netscape 4 DOM Reference available at:
        *


        * Internet Explorer DOM Reference available at:
        *
        Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


        * 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-deve...upgrade_2.html


        Comment

        Working...