query string - Getting QueryString from Request or Javascript - Stack Overflow

In aspx I have a querystring - www.mysiteenter.aspx?dest=#. When I click "enter" I go to mai

In aspx I have a querystring - www.mysite/enter.aspx?dest=#. When I click "enter" I go to main.aspx. I want to get this "?dest=#" in main.aspx with a request.querystring or something in javascript. I need to use the querystring in javascript in main.aspx for another action.

Any ideas?

let me explain in detail - I have enter.aspx page that shall load with a querystring - www.mysite/enter.aspx?dest=#. Now when i click the Enter button on Enter.aspx page, it shall goto Main.aspx page. When main.aspx page loads i want to write small javascript in main.aspx that shall get the querystring from the previous enter.aspx page and give it an if condition. so if (request.querystring('dest=') > 0 window.open ('a1.jpg') this above code needs to be redesigned so it can work. how can i do this. i tried window.location.href.indexof('dest') , nothing happened.

In aspx I have a querystring - www.mysite./enter.aspx?dest=#. When I click "enter" I go to main.aspx. I want to get this "?dest=#" in main.aspx with a request.querystring or something in javascript. I need to use the querystring in javascript in main.aspx for another action.

Any ideas?

let me explain in detail - I have enter.aspx page that shall load with a querystring - www.mysite./enter.aspx?dest=#. Now when i click the Enter button on Enter.aspx page, it shall goto Main.aspx page. When main.aspx page loads i want to write small javascript in main.aspx that shall get the querystring from the previous enter.aspx page and give it an if condition. so if (request.querystring('dest=') > 0 window.open ('a1.jpg') this above code needs to be redesigned so it can work. how can i do this. i tried window.location.href.indexof('dest') , nothing happened.

Share Improve this question edited Jan 19, 2010 at 19:33 poikuu asked Jan 19, 2010 at 19:18 poikuupoikuu 251 silver badge2 bronze badges 1
  • 3 Please slow down and try to make your question much, much clearer. – Telemachus Commented Jan 19, 2010 at 19:20
Add a ment  | 

6 Answers 6

Reset to default 3
alert(window.location.search); // ?dest=#

This is a bit messy.. YUI has a simple method to get at the querystring response by Gavin Brock.

How do you get querystring using YUI 2?

To get the current address in javascript you could use window.location.href and test if it contains a given string:

<script type="text/javascript">
if (window.location.href.indexOf('dest=') > 0) {
    window.open('images/newyork.jpg','','') 
}
</script>

If you don't have to do this in Javascript, you can always grab the querystring in the codebehind of enter.aspx, then perform a Response.Redirect to main.aspx, appending on the querystring.

If you want to get the url from the previous page, you should use "document.referrer".

<script type="text/javascript">
if (document.referrer.indexOf('dest=') > 0) {
    window.open("a1.jpg");
}

Yes. You can read the querystring from JavaScript. Here are some links to get you started:

  • http://javascript.about./library/blqs1.htm
  • http://ilovethecode./Javascript/Javascript-Tutorials-How_To-Easy/Get_Query_String_Using_Javascript.shtml
  • Link

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745144009a4613562.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信