473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Javascript, Embedded Objects, and Unload Event

Here is a complete web page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>Javascript Embed and onunload</title>
<script type="text/javascript">
function useplayer() {
var a = document.getElementById("obj1");
var obj = document.createElement("object");
obj.data = "dayenu.mid";
obj.type = "audio/x-midi";
obj.height = 60;
obj.width = 120;
a.parentNode.replaceChild(obj,a);
}
function donothing() {}
/* if (window.addEventListener)
addEventListener("unload",donothing,false); */
</script>
</head>
<body>
<div id="div1">
<a href="unload3.html">Navigate from page</a><br>
<a id="obj1" href="javascript:useplayer();">Use Embedded Object</a>
</div>
</body>
</html>

I have copies of it at http://www.dayenu.com/test2/unload1.html (with
the addEventListener line commented out), and
http://www.dayenu.com/test2/unload2.html (with the addEventListener
line uncommented). The one commented line is the only difference. Now
for my question.

If I bring up unload1.html in Firefox or Opera or Safari (this question
doesn't apply to IE) and click on the "Use Embedded Object" link, the
link will be replaced by an embedded object which plays my song. When I
click on "navigate from page", I get a new page; when I use the back
button, my object is still embedded and starts playing.

When I do the same thing with unload2.html, the first click acts the
same, and clicking on "navigate from page" acts the same. However, when
I use the back button now, the page to which I return shows the
original "use embedded object" link, not the embedded object. The only
difference between the 2 pages is that, at unload time for unload2, I
executed a function which does *nothing*. Can anyone tell me why this
causes such a difference in behavior?

Jan 4 '07 #1
2 8141
Owen.Leibman wrote:
<snip>
If I bring up unload1.html in Firefox or Opera or Safari
(this question doesn't apply to IE) and click on the "Use
Embedded Object" link, the link will be replaced by an
embedded object which plays my song. When I click on
"navigate from page", I get a new page; when I use the
back button, my object is still embedded and starts playing.

When I do the same thing with unload2.html, the first click
acts the same, and clicking on "navigate from page" acts
the same. However, when I use the back button now, the page
to which I return shows the original "use embedded object"
link, not the embedded object. The only difference between
the 2 pages is that, at unload time for unload2, I executed
a function which does *nothing*. Can anyone tell me why this
causes such a difference in behavior?
It looks like you are seeing the 'in-memory' caching of previously
viewed web pages. That is generally a good idea as it allows for the
back button to operate very quickly. However, if the page includes an
onuload handler (frequently necessitated by IE's memory leak problems),
and that handler is executed when the page is navigated away from, then
the page in memory will be in an 'unloaded' state that will not
necessarily be appropriate for re-display as it is. So a reasonable
strategy would be to only store a page in memory for re-disarray on the
use of the back button if it did not have an onuload (and probably
onload) handler, and when the page did have such handlers it would make
more sense to re-load the page (from the browser's cache or from the
network) so that it could go into its loaded state as it normally would.

Richard.
Jan 4 '07 #2
Thanks. It seems a bit unexpected, but I think that explanation helps.

Richard Cornford wrote:
Owen.Leibman wrote:
<snip>
If I bring up unload1.html in Firefox or Opera or Safari
(this question doesn't apply to IE) and click on the "Use
Embedded Object" link, the link will be replaced by an
embedded object which plays my song. When I click on
"navigate from page", I get a new page; when I use the
back button, my object is still embedded and starts playing.

When I do the same thing with unload2.html, the first click
acts the same, and clicking on "navigate from page" acts
the same. However, when I use the back button now, the page
to which I return shows the original "use embedded object"
link, not the embedded object. The only difference between
the 2 pages is that, at unload time for unload2, I executed
a function which does *nothing*. Can anyone tell me why this
causes such a difference in behavior?

It looks like you are seeing the 'in-memory' caching of previously
viewed web pages. That is generally a good idea as it allows for the
back button to operate very quickly. However, if the page includes an
onuload handler (frequently necessitated by IE's memory leak problems),
and that handler is executed when the page is navigated away from, then
the page in memory will be in an 'unloaded' state that will not
necessarily be appropriate for re-display as it is. So a reasonable
strategy would be to only store a page in memory for re-disarray on the
use of the back button if it did not have an onuload (and probably
onload) handler, and when the page did have such handlers it would make
more sense to re-load the page (from the browser's cache or from the
network) so that it could go into its loaded state as it normally would.

Richard.
Jan 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mad Scientist Jr | last post by:
I have some javascript I would like to run after a doPostBack occurs: onchange="javascript:__doPostBack('Text1','');" The doPostBack is being added dynamically by .NET when it renders the...
3
by: Gauthier Segay | last post by:
Hello, I've an application where all my pages implement a PAGE_CODE string property, this property is stored in HttpContext.Current.Items. In some page, I must persist data in session while...
3
by: vvenk | last post by:
Hello: I was trying to destroy objects in the Page_Unload event. That's when I see that the Page_Unload event gets triggered when I load a page, right after it completes page_load event! Why?...
60
by: marss | last post by:
Maybe anyone know good free online JavaScript knowledge test? This not exactly a system for testing online required - it may be simply list of questions with variants of answers (I have to prepare...
9
by: Joshua | last post by:
I posted this originally in the csharp group, but I think that may be the wrong group. This seems more appropriate: I'm running into an issue with a memory leak in an Asp.Net web page. In the...
1
by: abirami elango | last post by:
Hi, i have created a web application in vb.net. i have assigned a value to the textbox during page UNLOAD event as below.. ......... Protected Sub Page_Unload(ByVal sender As Object, ByVal e As...
1
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.