By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,628 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,628 IT Pros & Developers. It's quick & easy.

Variable Substitution Using Query String Params - PLEASE HELP

P: n/a
OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,
www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip
Feb 12 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Feb 11, 10:17 pm, Skip <wrote:
OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#v..."
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BA*K-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segment*s/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip
This is not a javascript answer but I think it might work for
you...you can use server-side language...I prefer PHP. In php a simple
version

URL: www.sitename.com/site.php?video=myvideoname
script for PHP
<?php //php start tag
if(isset($_GET['video']) && $_GET['video'] != "")) \\deterimines if
the URL var is set
{
?>
<object>
flash stuff...i wasn't sure where you wanted to use it.
<embed src="../<?php echo $_GET['video'];
//echo will write the contents to screen of the url var 'video'
}//end if
?>.swf" ... />
</object>

let me know if that makes sences.

Adambrz
Adambrz.com

Feb 12 '07 #2

P: n/a
JS' objects are extensible. The window object is a global object. So
after working on your url parameters, you may then add new variables
to the window object like:
window.var1 = "foo";
window.var2 = "bar";

these variables (object properties) are then all accessible within
this window (mind you an (i)frame is a new window). Or even better. If
you open the new window yourself, you may access the properties of the
parent window (no need for url parameters):

// main window:
window.var1 = "foo"; url = "somepage.html"; options =
"width=400,height=400";
window.open(url, "newWindow", options);

// in newWindow:
window.myVar1 = opener.var1; // opener is the window object of the
parent window
alert(window.myVar1); // should show "foo";

method 2 does only work if you (the user) opens the new window. due to
security measures js is not allowed to access properties in windows
created by other pages/served from other domains.

HTH,
Simon
On Feb 12, 5:17 am, Skip <wrote:
OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#v..."
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip

Feb 12 '07 #3

P: n/a
// url = www.myhome.com/mypage?video=BAK-Extension&b=2

var parameters = new Array();
// remove the "?" from the leading query string
var query = window.search.substr(1);
// query = "video=BAK-Extension&b=2"
var qParis = query.split("&"); // array with "name=value" pairs
for (i=0; i<qPairs.length; i++) {
var nv = qPairs[i].split("=");
parameters[nv[0]] = nv[1]; // mind you, you might have to unescape
}
// all passed url parameters are now in an associative array
// parameters, it should look like:
// parameters["video"] = "BAK-Extension";
// parameters["b"] = "2";
HTH
-S

PS: no tested from the top of my head ... might have typos. is JS 1.0
compatible.

On Feb 12, 5:17 am, Skip <wrote:
OK, I'm a novice in JS but have lots of coding experience. I am
trying to accomplish something that would seem somewhat simple - BUT
IT'S NOT.

I have a basic window that calls another window with window.open and
passes in 1 value using a querystring i.e.,www.myhome.com/mypage?video=BAK-Extension

Now when the window opens, I can capture the passed value in a JS
function. But if I want to use that in the body of the HTML in a
string substitution, how do I do that?

Here is my example:

<body onload="MM_CheckFlashVersion('7,0,0,0','Content on this page
requires a newer version of Macromedia Flash Player. Do you want to
download it now?')";>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#v..."
width="400" height="300" id="FLVPlayer">
<param name="movie" value="FLVPlayer_Progressive.swf" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars"
value="&MM_ComponentVersion=1&skinName=Corona_Skin _3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
/>
<embed src="FLVPlayer_Progressive.swf" width="400" height="300"
flashvars="&MM_ComponentVersion=1&skinName=Corona_ Skin_3&streamName=segments/BAK-BandBackExtension&autoPlay=true&autoRewind=false"
quality="high" scale="noscale" name="FLVPlayer" salign="LT"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>

In the object definition I want to substitute the occurences of
BAK-BandBackExtension with whatever is passed in as a variable. I
think that %var% notation will work but I don't know how to get the
variable that is passed in scoped to the level that I can see it in
the body of my HTML - or maybe that is completely backwards or non-OO
thinking.

I'm just looking for ANY solution, elegant or otherwise.

This app just takes input from a window and plays a specific Flash
video based on a thumbnail that was clicked.

Thanks so much in advance. i know there is a guru out there who can
do this while sleeping.

Skip


Feb 12 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.