SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast guioconnor's Avatar
    Join Date
    Oct 2007
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Replace the whole page with javascript

    Hi,

    I apologize if this has been discussed before, but my searches couldn't find it.

    I have a variable holding an full HTML page in response to an Ajax query. I want to replace the current page (entirely) for the new one with javascript. How can I do this?

    Thanks!
    Guilherme Zühlke O'Connor
    www.z-oc.com

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    About the best yu will do with that technique is
    document.body.innerHTML = newpage;

    *shudder*

    A much better way will be to not use AJAX and have the server show the new page instead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast guioconnor's Avatar
    Join Date
    Oct 2007
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    About the best yu will do with that technique is
    document.body.innerHTML = newpage;

    *shudder*

    A much better way will be to not use AJAX and have the server show the new page instead.
    Thanks for the answer.

    It might be better not to use Ajax in this case, but I think I'll dig on the server side and get smaller elements to replace in the page.

    The problem is that for each request, there are several points of the page that should change, I'd probably have to parse some XML.
    Guilherme Zühlke O'Connor
    www.z-oc.com


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
  •