Thursday, March 22, 2012

Setting the query string from a java script

Hi,
I would like to read some variables from a javascript located in the head
tags. The script is a simple document.location = new location, but i would
like to set the querystring.
How can i do this, if it is possible'
ThanksLoui,
Do you need to add the query string to the script after it's already posted
client side? or are you creating the script in your codebehind and
outputting it to the page?
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Loui Mercieca" <loui@.destiny-creations.com> wrote in message
news:OoH%23juMsFHA.3628@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I would like to read some variables from a javascript located in the head
> tags. The script is a simple document.location = new location, but i would
> like to set the querystring.
> How can i do this, if it is possible'
> Thanks
>
I want to redirect to an asp page. The only way for this that worked is to
create a javascript on the client and redirect from there. So, i am creating
the script in the client like so:
<HEAD>
<title>[title]</title>
<script>
function redir()
{
//var url="http://localhost/AspOnlineSurvey/Thanks-DE.aspx";
document.location="http://localhost/AspOnlineSurvey/Thanks-DE.asp?lang=";
}
</script>
</HEAD>
I tried unsuccessfully also:
Page.RegisterStartupScript("MyRedirectScript", "<script
language=""javascript"">window.location =
http://localhost/AspOnlineSurvey/Thanks-DE.asp"";</script> )
Thanks,
"S. Justin Gengo" <sjgengo@.[no_spam_please]aboutfortunate.com> wrote in
message news:uekdn7MsFHA.2880@.TK2MSFTNGP12.phx.gbl...
> Loui,
> Do you need to add the query string to the script after it's already
> posted client side? or are you creating the script in your codebehind and
> outputting it to the page?
> --
> Sincerely,
> S. Justin Gengo, MCP
> Web Developer / Programmer
> www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
> "Loui Mercieca" <loui@.destiny-creations.com> wrote in message
> news:OoH%23juMsFHA.3628@.TK2MSFTNGP10.phx.gbl...
>
Loui,
I just tested this out on a page and have it working. It will let you set
all your querystring parameters from the code behind which should be much
easier than attempting it client side.
Just paste this into a page load to test...
Dim MyId As Int32 = 1
Dim MySecondId As Int32 = 2
Page.RegisterStartupScript("MyScript", "<script
language=""javascript"">java script:window.location='http://www.aboutfortunat
e.com?id="
& MyId.ToString & "&id2=" & MySecondId.ToString & "';</script>")
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Loui Mercieca" <loui@.destiny-creations.com> wrote in message
news:eFUQv$MsFHA.2540@.TK2MSFTNGP09.phx.gbl...
>I want to redirect to an asp page. The only way for this that worked is to
>create a javascript on the client and redirect from there. So, i am
>creating the script in the client like so:
> <HEAD>
> <title>[title]</title>
> <script>
> function redir()
> {
> //var url="http://localhost/AspOnlineSurvey/Thanks-DE.aspx";
> document.location="http://localhost/AspOnlineSurvey/Thanks-DE.asp?lang=";
> }
> </script>
> </HEAD>
> I tried unsuccessfully also:
> Page.RegisterStartupScript("MyRedirectScript", "<script
> language=""javascript"">window.location =
> http://localhost/AspOnlineSurvey/Thanks-DE.asp"";</script> )
> Thanks,
> "S. Justin Gengo" <sjgengo@.[no_spam_please]aboutfortunate.com> wrote in
> message news:uekdn7MsFHA.2880@.TK2MSFTNGP12.phx.gbl...
>
Just taking a look at the original code I sent you that didn't work...
I noticed that it didn't work because I left a single apostraphe at the
beginning of the url out.
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"S. Justin Gengo" <sjgengo@.[no_spam_please]aboutfortunate.com> wrote in
message news:eIUJtaNsFHA.3340@.TK2MSFTNGP15.phx.gbl...
> Loui,
> I just tested this out on a page and have it working. It will let you set
> all your querystring parameters from the code behind which should be much
> easier than attempting it client side.
> Just paste this into a page load to test...
> Dim MyId As Int32 = 1
> Dim MySecondId As Int32 = 2
> Page.RegisterStartupScript("MyScript", "<script
> language=""javascript"">java script:window.location='http://www.aboutfortun
ate.com?id="
> & MyId.ToString & "&id2=" & MySecondId.ToString & "';</script>")
>
> --
> Sincerely,
> S. Justin Gengo, MCP
> Web Developer / Programmer
> www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
> "Loui Mercieca" <loui@.destiny-creations.com> wrote in message
> news:eFUQv$MsFHA.2540@.TK2MSFTNGP09.phx.gbl...
>
Thanks a lot Justin!!
"S. Justin Gengo" <sjgengo@.[no_spam_please]aboutfortunate.com> wrote in
message news:eEhB0cNsFHA.4044@.TK2MSFTNGP09.phx.gbl...
> Just taking a look at the original code I sent you that didn't work...
> I noticed that it didn't work because I left a single apostraphe at the
> beginning of the url out.
> --
> Sincerely,
> S. Justin Gengo, MCP
> Web Developer / Programmer
> www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
> "S. Justin Gengo" <sjgengo@.[no_spam_please]aboutfortunate.com> wrote in
> message news:eIUJtaNsFHA.3340@.TK2MSFTNGP15.phx.gbl...
>

0 comments:

Post a Comment