Menu

#16 Executing SWFAddress after DOMLoaded breaks initialisation

open
nobody
None
5
2010-02-05
2010-02-05
Anonymous
No

My page contains flash content, and an alternative html content with its own scripting, that's why i chose loading SWFAddress with jQuery directly before creating the flash content.
The problem is that after the page loaded, the SWFAddress._load() function never executes, which breaks (among other thing) the back/forward buttons.
Tested on Firefox 3.0/Win, Firefox 3.5/Mac, where problem occurs neary every time, but it also happens sometimes in Safari 4/Mac.

These are the important parts from the index.html and swfaddress.js:

==== index.html ====
<head>
<script src="jquery.js">
<script src="swfobject.js">
<script>
$(function(){ // on dom ready

if(swfobject.hasFlashPlayerVersion('8')){

$.getScript('/scripts/swfaddress/swfaddress.uncompressed.js' // execute swfaddress
,function(){
swfobject.embedSWF('site.swf','content', etc. ); // create our flash after swfaddress has executed
});

}else{
initHTML(); //alternate html content
}

});
</script>
</head><etc>

==== swfaddress.uncompressed.js ====
var SWFAddress = new function() {
...

//here is the suggested place of fix:
//execute load instantly
if( is page already loaded? ) _load();

// if page is already loaded, _load() function won't ever initialise anything
if(window==_t) _events.addListener(document, 'DOMContentLoaded', _functions.bind(_load, this));
_events.addListener(_t, 'load', _functions.bind(_load, this));

...
}

Discussion

  • Bizi Clop

    Bizi Clop - 2010-02-05

    Well, the suggested fix by me is not really working :(

     
  • Bizi Clop

    Bizi Clop - 2010-02-05

    Well, it does work, i forgot to include my modified/renamed js :)

     
  • Bizi Clop

    Bizi Clop - 2010-02-05

    Instead of
    _load();
    use
    _load.apply(this);
    like the bind() functions below it.

     

Log in to post a comment.