I have a bizarre situation in IE where JS can't call up into flash using ExternalInterface after I hit "refresh". I know the movie is getting loaded and the code that does the ExternalInterface.addCallback()
appears to be completing without any error
Here's a rundown of the steps to reproduce:
- Open IE and load up the movie for the first time, the ExternalInterface callback methods are available to JavaScript.
- If I hit refresh, the callback methods aren't available and I get the error
Object doesn't support this property or method
. - If I clear my cache and refresh the page, they are available again.
- If I then hit refresh again without clearing my cache, they're unavailable.
- If I close the browser and reopen, they're available again.
I've run into this situation before and I'm pretty sure that the extra delay required to download and instantiate the swf is what's allowing ExternalInterface to get set up properly. The way I worked around this before was to add a random number to the end of the swf's url, so that it's never used from cache, but that's not a real solution.
Does anyone know how to solve this?
edit:
I should have mentioned as well that after refreshing, 'ExternalInterface.available' is 'true', but 'ExternalInterface.objectId' is 'null'.
I've tried randomizing the value of the object id
and embed name
and the id of the container div and in every case, ExternalInterface.objectId
remains null
.
More info:
I can't see how the way I'm inserting the movie would make a difference, but I thought I would include the code just to be sure. My movie is not affected by the "click to activate" issue and I don't want to use SWFObject in this case since the flash movie is a fallback in case HTML5 audio is not available.
var docContainer = document.createElement('div');
docContainer.innerHTML = '<object '
+ 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
+ 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" '
+ 'id="mp3player" '
+ 'width="300" '
+ 'height="500">'
+ '<param name="allowScriptAccess" value="always" />'
+ '<param name="movie" value="mp3player.swf" />'
+ '<param name="quality" value="high" />'
+ '<param name="bgcolor" value="#ffffff" />'
+ '<embed '
+'src="mp3player.swf" '
+ 'quality="high" '
+ 'bgcolor="#ffffff" '
+ 'width="300" '
+ 'height="500" '
+ 'swLiveConnect="true" '
+ 'name="mp3player" '
+ 'id="mp3player" '
+ 'allowScriptAccess="always" '
+ 'type="application/x-shockwave-flash" '
+ 'pluginspage="http://www.adobe.com/go/getflashplayer" />'
+ '</object>';
document.body.appendChild(docContainer);