|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
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 |
|
#6
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Firefox not running javascript in a page on return |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|