Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
How to combine these two JS codes so a page refreshes when back button is clicked?
Old 09-22-2009, 06:04 PM How to combine these two JS codes so a page refreshes when back button is clicked?
Super Talker

Posts: 101
Trades: 0
Hi Guys,

I have these two JavaScript codes:

HTML Code:
<a href="javascript:location.reload(true)">Refresh this page</a>
This one ^ refreshes a page when clicked

HTML Code:
<a href="#" onclick="history.go(-1);return false;">< Go Back</a>
And this one ^ takes the clicker back to the page they were previously viewing

I was wondering if both these pieces of code could be combined so that when the "Go Back" link is clicked the previous page would come back but refreshed.
Towhid is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-22-2009, 06:12 PM Re: How to combine these two JS codes so a page refreshes when back button is clicked
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Nope.
Because "history.go(-1)" is the same as clicking the back button in your browser.

It reload the url previously opened, and use it's cache.
The only way to defeat cache, would be a real link, with a seed to force refetching.
like
HTML Code:
<html>
<script type="text/javascript">
seed=new Date().getTime()
</script>
<a href=javascript:top.location="http://www.whatever.com/pageX.html?seed="+seed>Go back</a>
</html>
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 09-22-2009 at 06:27 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-22-2009, 06:25 PM Re: How to combine these two JS codes so a page refreshes when back button is clicked
Super Talker

Posts: 101
Trades: 0
No, that just refreshes the same page it doesn't take one back.
Towhid is offline
Reply With Quote
View Public Profile
 
Old 09-22-2009, 08:18 PM Re: How to combine these two JS codes so a page refreshes when back button is clicked
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
There's no "refresh the same page".
The fact is that your browser is either intellignent enough to recognize the page should still be the same, or too dumb to see that the given parameter should force it to refresh it.

There is no magical trick here. It can be a server configuration too, that cause this problem.
If this don't work, then you will need to use something more radical,like an empty post to get back on that page.

What is the result if you have a normal link, rather than some javascript to get you back to your page ?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-23-2009, 12:45 PM Re: How to combine these two JS codes so a page refreshes when back button is clicked
Super Talker

Posts: 101
Trades: 0
Quote:
Originally Posted by tripy View Post
There's no "refresh the same page".
The fact is that your browser is either intellignent enough to recognize the page should still be the same, or too dumb to see that the given parameter should force it to refresh it.

There is no magical trick here. It can be a server configuration too, that cause this problem.
If this don't work, then you will need to use something more radical,like an empty post to get back on that page.

What is the result if you have a normal link, rather than some javascript to get you back to your page ?

Alright thanks. I initially needed this for a "captcha error message" related issue but I got the code for that fixed so I no longer need this.
Towhid is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to combine these two JS codes so a page refreshes when back button is clicked?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50206 seconds with 12 queries