Results 1 to 3 of 3

Thread: retrieve and store url's html page source in java script variable

  1. #1
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default retrieve and store url's html page source in java script variable

    we have an url link in our java script. then how to retrieve and store url's html page source in java script variable ?

    if any one know solution please help me asap...

  2. #2
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    I don't think you can get a pages source code* using javascript. You'd have to use php.


    *You do mean source code don't you?

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I would generally agree. However, using javascript it is possible to read the current state of the page from and including the opening head tag down to and including the closing body tag. This will be how the browser interprets the document's innerHTML property, which varies. Some see the current state of the DOM, others more of the original source code depending upon if and how the DOM was changed. A real time test or tests could probably be performed to determine which. Cookies aren't suitable for this (too much data), but localStorage could be used to save the data on the user's computer for later retrieval on the web site that stored it there for that one user.

    For anything more permanent (localStorage, like cookies can be cleared by the user), or to be available to more than the one user who saved it for retrieval, a server side solution would be required.

    And, regardless of method, one should consider if the entire page is what one really wants to save. More likely there are certain key pieces of information that would suffice.
    Last edited by jscheuer1; 03-22-2012 at 02:24 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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