I have a plain html web page with an embedded flash object. Based on presence of a query string, I want to vary one of the paramters to the object, so I wrote something like this:
<object ...>
<param ...>
<param ...>
<script type="text/javascript">
if (window.location.search.indexOf("stuff")>=0) {
document.write("<param variant 1>");
} else {
document.write("<param variant 2>");
}
</script>
</object>
It works great in Firefox, but IE8 does not execute the js code, at all. I replaced the entire script with a simple alert(“a”) call, and that was not executed by IE8, either. Using the developer tool, I can see the script, but it’s not highlighted, nor can I set a breakpoint in it, so I’m pretty sure it’s not acknowledging it as a valid script.
Is this an IE restriction, or am I missing something?
I’ve replaced the whole with document.write calls, and that works fine, but I’d prefer something closer to my original attempt.
I think the problem lies in the DOM and with Internet Explorer seemingly not executing in-line JavaScipt.
Waiting for the window to load before initialising, and then adding the parameters as children (rather than writing HTML) is the proper way to go, it seems.
The following worked as expected in both Firefox and Internet Explorer.