I have the following simple object embed for Flash:
<object id="siwp_obj"
type="application/x-shockwave-flash"
data="button.swf?file=%2F/ex.php?id=89804c7326e92a00c5c88c181190af8159cf060b"
height="32" width="32">
<param id="siwp_param" name="movie"
value="button.swf?file=%2F/ex.php?id=89804c7326e92a00c5c88c181190af8159cf060b" />
</object>
What I want to do is replace the id parameter with a new ID that is generated by the browser.
I've tried this, which works in Firefox but not in Chrome or IE9. Firefox successfully updates the parameters so the Flash object references the new ID, but Chrome and IE9 don't update ID, or result in any script errors or warnings.
var cid = "randomstring";
var obj = document.getElementById('siwp_obj');
// get the "data" attribute which contains the URL with an old id to replace
obj.setAttribute('data', obj.getAttribute('data').replace(/[a-zA-Z0-9]{40}$/, cid));
obj = document.getElementById('siwp_param');
obj.value = obj.value.replace(/[a-zA-Z0-9]{40}$/, cid);
I'm trying to assume no javascript libraries are available since this will be used in a plugin system.
Does anyone have any ideas on how to update the URLs for the object and param tag dynamically?
EDIT:
In Chrome, I did some debugging and noticed that the parameter is being updated, but when I interact with the flash, it hasn't been reloaded.
For example:
var obj = document.getElementById('siwp_obj');
alert(obj.getAttribute('data')); // the old URL with old ID
obj.setAttribute('data', obj.getAttribute('data').replace(/[a-zA-Z0-9]{40}$/, cid));
alert(obj.getAttribute('data')); // the new URL with new ID
...But when I click on the flash object to try to stream from the new URL, it still refers to the old URL with the old ID. So the DOM is being updated, but the browser is then missing the fact that some parameters to the object have changed. Any thoughts?
var cid = "<new random id:40>"