View Full Version : pull variables from URL and post in document code?

01-17-2009, 10:00 PM
my url read index.html?pagego=collections

here it he code I have that is pulling the variables from the URL

function getUrlVars(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

for(var i = 0; i < hashes.length; i++){
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];

return vars;

and here is the code I use to alert

var hash = getUrlVars();

this works perfectly and alerts with the variable when I load he page.

Now when i am embedding my flash file i want to pass the variable to my flash by just adding the variable value to my embed code.

how can I do this?

here is my swf embed code

var so = new SWFObject("main2.swf?pagego="+THIS IS WHERE I WANT THE VARIABLE TO BE, "Preview", "100%", "100%", "9", "#ffffff", true);
so.addParam("scale", "noscale");
so.addParam("salign", "lt");

01-18-2009, 12:41 AM
var so = new SWFObject("main2.swf?pagego="+hash["pagego"], "Preview", "100%", "100%", "9", "#ffffff", true);
so.addParam("scale", "noscale");
so.addParam("salign", "lt");