promisefeni / reallysimplehistory

Automatically exported from code.google.com/p/reallysimplehistory
Other
0 stars 0 forks source link

RSH clobbers window.onunload #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add dhtmlHistory.js to a page that already has an onunload handler, like
this:
<script type="text/javascript">
window.onunload = function() { alert("my unload handler"); }
</script>
<script type="text/javascript" src="dhtmlHistory.js"></script>
2. Note that the onunload handler you added doesn't get run.

What is the expected output? What do you see instead?

I expect the library to run the existing onunload handler before doing the
onunload cleanup that it needs to do.  Instead, the onunload handler is
clobbered.

What version of the product are you using? On what operating system?

.04 on all browsers.

Please provide any additional information below.

I believe the following patch will work.  Replace these lines:

      var self = this;
      window.onunload = function() {
         self.firstLoad = null;
      };

with these lines:

      var self = this;
      var previousOnUnload = window.onunload;
      window.onunload = function() {
         self.firstLoad = null;
         if (previousOnUnload) previousOnUnload();
      };

Original issue reported on code.google.com by xan...@gmail.com on 2 Oct 2007 at 6:13

GoogleCodeExporter commented 8 years ago
Sorry, meant to say "I expect the library to run the existing onunload handler 
AFTER
doing the onunload cleanup that it needs to do."

Original comment by xan...@gmail.com on 2 Oct 2007 at 6:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Xander, thanks for the suggested patch. I ended up fixing this with a fairly 
standard
cross-browser event registration method. There's no way to guarantee execution 
order
of unload events registered this way, but I don't think it should matter. I 
can't
imagine a scenario where somebody would be relying on a non-null value for
dhtmlHistory.firstLoad during their own custom unload events.

Original comment by bdpathfi...@gmail.com on 7 Nov 2007 at 9:25