JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 3rd, 2006, 08:31 AM
bobfriston bobfriston is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 3 bobfriston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 37 sec
Reputation Power: 0
Firefox not running javascript in a page on return

Hi All

I don't know if I'm going mad here and have missed something extremely obviouse (i really hope so), but I cannot for the life of me understand the following problem. When navigating Back from one simple page to a previouse simple page that happens to have some javascript content, in most browsers other than IE(pc) and Opera(pc) the javascript fails to run on using the browser Back button!!!!

Surely this cannot be intentional as a security feature!

Thanks
Bob

Here are my example pages.

[PAGE1.HTML]
<html>
<body onload="alert('I am page1.html')">
<a href="page2.html">Click to go to page2.html</a>
</body>
</html>

[PAGE2.HTML]
<html>
<body onload="alert('I am page2.html')">
Now use the browser back button in FireFox(PC) or FireFox/Safari/Opera(Mac)<br>
and the onload event fails to trigger in page1 !!!!
</body>
</html>

Reply With Quote
  #2  
Old March 3rd, 2006, 09:47 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 548 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 6 h 35 m 44 sec
Reputation Power: 4
back button

Hi bobfriston, welcome to the forums,
I don't know if this is what is happening, but it sounds like:
The browser, when using the back button, is using a cached page. Because no HTTP request is being made, no onload event is fired. No onload event, no javascipt alert.

Reply With Quote
  #3  
Old March 3rd, 2006, 10:15 AM
bobfriston bobfriston is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 3 bobfriston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 37 sec
Reputation Power: 0
Hi, Mittineague (how on earth do you pronounce that

I wanted to just check this theory (as it sounds totally logical), so i included the follwing into the page1 code block

Code:
<head><script>alert('ok - im a fool')</script></head>


and blow me down, even this does not work in those browsers mentioned before (no problem in IE though). So unfortunately that theory is out the window. Thanks very much for your quick response.

Bob

Reply With Quote
  #4  
Old March 6th, 2006, 07:16 AM
bobfriston bobfriston is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 3 bobfriston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 37 sec
Reputation Power: 0
Hi

I have at last found the reason for this odd behaviour, as is explained in detail here:

http://developer.mozilla.org/en/docs/Using_Firefox_1.5_caching

Seems like an interesting development, but I can't help but think there must be many web developers out there that are going to get caught out by this shift. Oh well, onwards and upwards

Thanks
Bob
Comments on this post
MadCowDzz agrees!

Reply With Quote
  #5  
Old March 6th, 2006, 07:42 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Great discovery Bob!
Thanks for the followup.

Adding a server-side no-cache header to your page may fix this? but it might cause some other complication.
I can see others bumping into this issue nonetheless.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #6  
Old March 8th, 2006, 11:32 PM
mrhoo mrhoo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 4 mrhoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 17 m 4 sec
Reputation Power: 0
Great catch bob! And MadCow, add an onunload handler to your code-

window.addEventListener('unload',quitit,false);

quitit can return true or nothing- the cache isn't supposed to 'remember' the 'live' page if there is an onunload handler present.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Firefox not running javascript in a page on return


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway