Javascript question

Beej

macrumors 68020
Original poster
Jan 6, 2002
2,139
0
Buffy's bedroom
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
169
1
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
Buffy's bedroom
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,077
1
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
Buffy's bedroom
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,077
1
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
169
1
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.