J
Jonathan Wood
I'm trying to duplicate an HTML sample I have using my ASP.NET pages.
The sample contains the following within the <head> tag:
<script type="text/javascript" src="flashobject.js"></script>
<script type="text/javascript">
// <![CDATA[
var args = new Object();
var query = location.search.substring(1);
// Get query string
var pairs = query.split( "," );
// Break at comma
for ( var i = 0; i < pairs.length; i++ )
{
var pos = pairs.indexOf('=');
if( pos == -1 )
{
continue; // Look for "name=value"
}
var argname = pairs.substring( 0, pos ); // If not found, skip
var value = pairs.substring( pos + 1 ); // Extract the name
args[argname] = unescape( value ); // Extract the value
}
// ]]>
</script>
To do this the ASP.NET way, I added the following code to my Page_Load
handler:
if (!Page.ClientScript.IsClientScriptBlockRegistered("FlashObject"))
Page.ClientScript.RegisterClientScriptInclude(typeof(Page),
"FlashObject", "flashobject.js");
if (!Page.ClientScript.IsStartupScriptRegistered("PrepVideo"))
Page.ClientScript.RegisterStartupScript(typeof(Page), "PrepVideo",
"var args=new Object();" +
"var query=location.search.substring(1);" +
"var pairs=query.split(',');" +
"for (var i=0;i < pairs.length;i++){" +
"var pos=pairs.indexOf('=');" +
"if (pos==-1) continue;" +
"var argname=pairs.substring(0,pos);" +
"var value=pairs.substring(pos + 1);" +
"args[argname]=unescape(value);}", true);
}
I assume the second script is a start-up script since it is not a callable
function. So this seems like it should work but it does not duplicate the
functionality of the sample.
Looking at the HTML produced, I see neither registered scripts are placed
within the <head> tag. So instead of calling RegisterClientScriptInclude and
RegisterStartupScript, I instead forced these scripts into the <head> tag
and they WORKED!!
Unfortunately, I need to put this in a control that really should register
the scripts in an organized way.
Is there any way to register a script such that it is inserted within the
<head> tag? Or perhaps there's something else I'm missing?
Thanks.
Jonathan
The sample contains the following within the <head> tag:
<script type="text/javascript" src="flashobject.js"></script>
<script type="text/javascript">
// <![CDATA[
var args = new Object();
var query = location.search.substring(1);
// Get query string
var pairs = query.split( "," );
// Break at comma
for ( var i = 0; i < pairs.length; i++ )
{
var pos = pairs.indexOf('=');
if( pos == -1 )
{
continue; // Look for "name=value"
}
var argname = pairs.substring( 0, pos ); // If not found, skip
var value = pairs.substring( pos + 1 ); // Extract the name
args[argname] = unescape( value ); // Extract the value
}
// ]]>
</script>
To do this the ASP.NET way, I added the following code to my Page_Load
handler:
if (!Page.ClientScript.IsClientScriptBlockRegistered("FlashObject"))
Page.ClientScript.RegisterClientScriptInclude(typeof(Page),
"FlashObject", "flashobject.js");
if (!Page.ClientScript.IsStartupScriptRegistered("PrepVideo"))
Page.ClientScript.RegisterStartupScript(typeof(Page), "PrepVideo",
"var args=new Object();" +
"var query=location.search.substring(1);" +
"var pairs=query.split(',');" +
"for (var i=0;i < pairs.length;i++){" +
"var pos=pairs.indexOf('=');" +
"if (pos==-1) continue;" +
"var argname=pairs.substring(0,pos);" +
"var value=pairs.substring(pos + 1);" +
"args[argname]=unescape(value);}", true);
}
I assume the second script is a start-up script since it is not a callable
function. So this seems like it should work but it does not duplicate the
functionality of the sample.
Looking at the HTML produced, I see neither registered scripts are placed
within the <head> tag. So instead of calling RegisterClientScriptInclude and
RegisterStartupScript, I instead forced these scripts into the <head> tag
and they WORKED!!
Unfortunately, I need to put this in a control that really should register
the scripts in an organized way.
Is there any way to register a script such that it is inserted within the
<head> tag? Or perhaps there's something else I'm missing?
Thanks.
Jonathan