Click to See Complete Forum and Search --> : <SCRIPT SRC= variable ?


gazolba
11-25-2002, 06:52 PM
I want to pass the value of my <SCRIPT SRC= to my page in a variable e.g.

<script language="javascript">
if (location.search) {
var parmsrc = location.search.substring(1);
}
</script>

<script src='"' + parmsrc + '"' type="text/javascript" language="Javascript">
document.write("Javascript source not found");
</script>

However, it is not working. Can this be done? I could not find it documented anywhere.
If there is any way to make this work, please let me know.

Thanks - David

Beach Bum
11-25-2002, 07:37 PM
don't think you can do that.

i tried playing around with it anyway to see if i could get it to work - no joy.

but - one idea - you could do the test in the js and then use document.write to write the js execution line depending on the answer - that might do what you want.

Rick Bull
11-26-2002, 03:31 AM
Or use a server-side method to write the querry string. Depends if you have one.

Vladdy
11-26-2002, 07:00 AM
scriptNode = document.createElement('script');
scriptNode.src = parmsrc;
scriptNode.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(scriptNode);

hambo
11-27-2002, 07:44 AM
like it Vladdy.

is this x browser...


Hambo

Vladdy
11-27-2002, 09:16 AM
DOM compliant method. Works fine in IE5+ and Gecko based browsers (>90% of browsing public).

ubshyam123
04-07-2011, 03:29 PM
Works absolutely fine.. Thanks a lot !! :) i have checked it with latest browsers and it works