Now that i learned how to pass values to an SWF object via flashvars, could you please guide me how can i pass values from a querystring to javascript?
What do i mean? In the following example i hard-code the xml file to load in the SWF object.
<script type="text/javascript">
var so = new SWFObject("preview.swf", "", "100%", "100%", "9", "#ffffff");
so.addParam("allowFullScreen", "true");
so.addParam("scale", "noscale");
so.addParam("menu", "false");
so.addVariable("xmlPath", "xml/exampleData.xml");
so.write("flashcontent");
</script>
Since the Xml file is created dynamic, the xml should be loaded from the value of a query-string. (I guess).
Supposing my url is http://www.example.com/load.aspx?XmlFile=SomeData
How can i pass it to the javascript side? Like..
so.addVariable("xmlPath", "xml/<% SomeData %>.xml");
or whatever it needs to make it work.
UPDATE: Besides the above example, is there any way of creating the JavaScript, in server-side?
Try something like:
function GetQueryString(param)
{
var url = window.location.search.substring(1);
var params = url.split("&");
for (i=0;i<params.length;i++)
{
var p = params[i].split("=");
if (p[0] == param)
{
return p[1];
}
}
}
And use it like:
so.addVariable("xmlPath", "xml/" + GetQueryString("XmlFile") + ".xml");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With