Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Beej

macrumors 68020
Original poster
Jan 6, 2002
2,139
0
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?
 

Lz0

macrumors regular
Jul 20, 2002
177
4
Melbourne
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+.
 

Beej

macrumors 68020
Original poster
Jan 6, 2002
2,139
0
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?
 

edesignuk

Moderator emeritus
Mar 25, 2002
19,232
2
London, England
Originally posted by Beej
verbose101 - I'm not sure what you mean, do I put that in the meta tag or inside a javascript function?
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: )
 

Beej

macrumors 68020
Original poster
Jan 6, 2002
2,139
0
Originally posted by verbose101

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: )
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...
 

edesignuk

Moderator emeritus
Mar 25, 2002
19,232
2
London, England
Originally posted by Beej
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...
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.
 

Lz0

macrumors regular
Jul 20, 2002
177
4
Melbourne
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.
 

Beej

macrumors 68020
Original poster
Jan 6, 2002
2,139
0
Originally posted by Lz0
You must be an IT Development/Project/Client Liasion Manager???
What makes you say that?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.