Javascript question

Discussion in 'Mac Help/Tips' started by Beej, Sep 22, 2002.

  1. Beej macrumors 68020

    Beej

    Joined:
    Jan 6, 2002
    Location:
    Buffy's bedroom
    #1
    Let me start by saying that my understanding of Javascript is almost 0 :)

    I'm trying to write a function that will take the user back to the page they came from, but not their cached version. Since
    window.location = history.back()
    takes the user back, and
    window.location = 'www.whatever.com'
    takes the user to whatever.com, I figure I can do somehting like this:
    var location = history.back()
    window.location = location

    but that (and all variations on it I can think of) doesn't work. Any ideas?
     
  2. Lz0 macrumors regular

    Joined:
    Jul 20, 2002
    Location:
    Melbourne
    #2
    On the page you don't want cached (previous page) put this meta tag.

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">

    The first line looks after all other browsers and the second IE5+.
     
  3. edesignuk Moderator emeritus

    edesignuk

    Joined:
    Mar 25, 2002
    Location:
    London, England
  4. Beej thread starter macrumors 68020

    Beej

    Joined:
    Jan 6, 2002
    Location:
    Buffy's bedroom
    #4
    Sorry, I should have said, I need this to be Javascript. I can't put anything Im my meta tags (don't ask why, I just can't :D)

    verbose101 - I'm not sure what you mean, do I put that in the meta tag or inside a javascript function?
     
  5. edesignuk Moderator emeritus

    edesignuk

    Joined:
    Mar 25, 2002
    Location:
    London, England
    #5
    For example, your "back" button could be...

    <a href="JavaScript:history.go(-1)">Back</a>

    (without the space between java & script, for some reason the forum puts the space in :confused: )
     
  6. Beej thread starter macrumors 68020

    Beej

    Joined:
    Jan 6, 2002
    Location:
    Buffy's bedroom
    #6
    Thanks but that doesn't solve my problem, your suggestion just uses the cached version. It's weird that it wants to put a space in JavaScript...
     
  7. edesignuk Moderator emeritus

    edesignuk

    Joined:
    Mar 25, 2002
    Location:
    London, England
    #7
    As Lz0 said, in the pages you do not want cached as far is I know you have to use the META tags, then the javascript funtion to go back.
     
  8. Lz0 macrumors regular

    Joined:
    Jul 20, 2002
    Location:
    Melbourne
    #8
    So you need to go back one page using JavaScript? That would be easy - as follows:

    <a href="java script:history.go(-1)">Back</a>

    But you want to get the page unchached but you don't have access to the page to insert this into it:

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">

    You must be an IT Development/Project/Client Liasion Manager???

    I'll have a think about IT???

    Get back to ya.
     
  9. Beej thread starter macrumors 68020

    Beej

    Joined:
    Jan 6, 2002
    Location:
    Buffy's bedroom
    #9
    What makes you say that?
     

Share This Page