#1
  1. No Profile Picture
    aooooooodaaa
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Location
    at a pc near you
    Posts
    32
    Rep Power
    13

    Question javascript: how to go back to previous page but refresh it too.?


    well the subject says it all. What i'm doing is that i've got a sign-up form. Since the signup form can be accessed from many pages, i'm trying to use javascript to go back to the page the person comes form. so what i'm using is this:

    PHP Code:
    <script language=javascript>window.history.go(-2);</script> 
    this works perfectly.. BUT.. in some browsers i have to press refresh to have the changes made.
    e.g. index.php says "hello guest"
    after signing in
    some browsers say "hello user"
    some like ie5 say "hello guest" (if i refresh, then it says "hello user")

    so is there anyway to goback to the previous page in history and not to use the cache?

    thanks
    it's electric baaaabbbbbbyyyyyy!!!
  2. #2
  3. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0
    If all you want is for the page to refresh itself every time it's loaded, just put:
    PHP Code:
    <body onload="document.refresh();"
    .If, on the other hand you don't want the page to cache at all, do a search of the forums. There was a recent thread about preventing browser caching that should answer that question.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    Never heard of document.refresh(). You can force an unconditional HTTP GET by doing this:

    window.location.reload(true);

    ...but you'd have to put in in every page - and every page would be refreshed, regardless of how the user got there. Need to keep it from looping endlessly as well. The history object is closely guarded, so, not much can be done with it client-side. You might be able to use document.referrer....

    http://www.faqts.com/knowledge_base/view.phtml/aid/1175

    http://developer.irt.org/script/306.htm
    Last edited by mrrichardfeder; March 17th, 2002 at 07:53 PM.
  6. #4
  7. An Ominous Coward
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2002
    Posts
    4,425
    Rep Power
    0


    .refresh().... well.. I suppose if one specified it as a method of a custom object with the block document.location.reload(true); then it would work jut the way one would expect, wouldn't it!

    That's what happens when you type without thinking.. it's the information ages answer to not thinking before you speak I suppose... sheesh.. yea yea... there's no .refresh() method! Sorry about that how-do-i, thanks mrrichardfeder!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    8
    Rep Power
    0

    Thumbs up


    I realize this is a really old thread, but it came up in the results when I was searching to fix this problem. So going to go ahead and put the answer I found to work in case anyone else finds it since it was the information in this thread that lead me to the answer.

    I had a similiar problem. I have a list of items, and in that list there is a "status" highlight that tells if that item needs attention or not(something needs fixed). So you click to edit the item, fix the item then resubmit. Problem is/was, the lists the person came from was not always the same place, so the history function was needed to get back to the list. Of course, without a refresh the status wasn't updated and that wasn't good.

    Here's what I did:

    Code:
    <a href="javascript:window.location.reload(history.go(-2));">Back<a>
    This took the browser back 2 pages and refreshed it. I've only tried this in IE, as it's all we use at work. So no idea if it works with other browsers.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    4
    Rep Power
    0

    Angry


    Does anyone know how to get this script working in Mozilla/Firefox - it works perfectly in IE 6, but not in Firefox...
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    4
    Rep Power
    0

    Unhappy


    Originally Posted by paliz
    Does anyone know how to get this script working in Mozilla/Firefox - it works perfectly in IE 6, but not in Firefox...
    yeah, doesn't work in Firefox 1.0 on linux, which is a real shame. it just reloads the existing frame.
    :-(
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    4
    Rep Power
    0
    Originally Posted by speculatrix
    yeah, doesn't work in Firefox 1.0 on linux, which is a real shame. it just reloads the existing frame.
    :-(
    just tried this in firefox http://www.webdevforums.com/textonly/t-4573
    but no joy either.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2009
    Posts
    1
    Rep Power
    0
    Again, I know it's old, but it's still one of the first matches I get when I google this, and there doesn't seem to be any good solution here.

    I had this same problem, and I figured out a way around it, though it's not quite as simple as I would have liked. What I did was I created a hidden input field in the form that was to be submitted and wrote a Javascript routine to place the URL of the current site into the hidden input field. That way, the server side VBScript has the desired URL already (I used VBScript, but it should work with any server side script as long as you are using ASP). Then, in the case of VBScript, use the Redirect method to redirect the user back to the page before.

    Anyway, the solution that was given before didn't even work in the newest version of Internet Explorer (IE 8), and it certainly didn't work in Firefox (which I primarily use). It's usually not good to use code that is highly browser-dependent anyway.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0
    Code:
    window.location = document.referrer;
    This helped me.
    Don't know if it's cross-browser friendly :s

IMN logo majestic logo threadwatch logo seochat tools logo