View Full Version : Javascript question
Beej
Sep 23, 2002, 12:45 AM
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
Sep 23, 2002, 06:26 AM
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+.
edesignuk
Sep 23, 2002, 07:18 AM
Try JavaScript:history.go(-1)
Beej
Sep 23, 2002, 09:23 AM
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
Sep 23, 2002, 01:29 PM
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
Sep 23, 2002, 06:43 PM
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
Sep 24, 2002, 04:12 PM
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
Sep 24, 2002, 11:33 PM
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
Sep 24, 2002, 11:39 PM
Originally posted by Lz0
You must be an IT Development/Project/Client Liasion Manager???What makes you say that?
vBulletin® v3.6.10, Copyright ©2000-2009, Jelsoft Enterprises Ltd.