Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Grabbing page source with Javascript

    Ok. I've been looking all night and can't find the answer. This may be impossible but I don't think it is:

    I want to use a javascript to pass the page source of an HTML document to a CGI script.

    All I need to find out is how do I assign the current page's source to a variable in javascript?

    I mean I know I can do something like:

    var t = document.title;

    And that gets me the title of the page. But how do I just get a dump of the document source?

    Is there a way?

    Any help would be very much appreciated!

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    document.documentElement.innerHTML will get you most of it, or IE has a "download behavior" which can get it 'as authored', or there's possibly a way to use a request method of an xml object (not sure...).
    *this message will self destruct in n-seconds*

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hrm...well I definately need all of the source. This sort of works but doesn't give me complete info....

    I would prefer to stay away from anything browser specific as I don't want to have to force the user into a browser....

    So what's the scoop with the XML stuff? From what I can find its something like: XMLHTTPRequest but that, from what I can tell, creates another request to the server. Can someone expand a little on this for me? An example script would be perfect as I learn by example...

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you need the current state of the source (if the DOM has been altered), then innerHTML might be the only way--short of inserting diffs into the original.
    The request object does its thing in-process, I think; there are several examples of its usage archived in these forums, btw.
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •