SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Location
    Vashon Island
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reload page with different URL variable.

    Hi All,

    I know I can make a link that reloads a page like this:

    <a href="thispage.php">Refresh this page</a>
    Or, using javascript:
    <a href="javascript:location.reload(true)">Refresh this page</a>

    I am starting from "thispage.php", and I want to reload it as "thispage.php?action=newversion"? (This page has a form that reloads the rest of the page with new data when refreshed with the action call).

    Is there a javascript technique that would do this without calling the "thispage.php" part? The page includes a function that I need to be portable to any page that I place it on.

    Obviously this is very wrong but I am trying to do this:

    <a href="javascript:location.reload(true) . ?action=newversion">Refresh this page</a>

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Location
    Internet
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Trying giving this ago:

    Code JavaScript:
    // Get the current page
    var curr_page = window.location.href,
        next_page = "";
     
    // If current page has a query string, append action to the end of the query string, else
    // create our query string
    if(curr_page.indexOf("?") > -1) {
        next_page = curr_page+"&action=someaction";
    } else {
        next_page = curr_page+"?action=someaction";
    }
     
    // Redirect to next page
    window.location = next_page;

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Location
    Vashon Island
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool! will try..


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
  •