0
<script language="JavaScript" type="text/javascript">
    if (location.href.indexOf('?dest=') > 0)
        window.open('/about.aspx', '', '')
</script> 

how do i make this work. Its in aspx file.

5
  • What exactly is happening? Can you be a little more descriptive about any errors or strange behavior caused by the code? Commented Jan 19, 2010 at 17:52
  • And what is supposed to happen? Commented Jan 19, 2010 at 17:52
  • im sorry. im very confused. i have first aspx page with <a href="login.aspx?dest=#" .. which goes to second page when clicked on it. On second page when i click "enter" i goto third page which has this code. I want to carry the dest=# to third page and based on this if condition a window should open. how do i achieve that? Commented Jan 19, 2010 at 18:00
  • 1
    FYI, window.location.search will return just the portion of the URL following the question mark, the querystring. Commented Jan 19, 2010 at 18:02
  • so how do i carry the querystring to 3rd page from the 2nd page and us the if condition? Commented Jan 19, 2010 at 18:03

3 Answers 3

2

The following script will test for the existence of the 'dest=' key in the current page's querystring, and if it exists, will open a window to about.aspx with the querystring appended to the URL.

<script language="JavaScript" type="text/javascript">
if (window.location.search.indexOf('dest=') > 0) {
    window.open('/about.aspx' + window.location.search, '', '');
}
</script> 
Sign up to request clarification or add additional context in comments.

Comments

0

Change the window.open line to

window.location = '/about.aspx';

Include the semicolon, which is missing in your code.

1 Comment

JavaScript doesn't strictly require a semicolon at the end of a statement.
0

Your issue is the location.href... part. It needs to be window.location.href...


if (window.location.href.indexOf('?dest=') > 0){
    window.open('/about.aspx'+window.location.search, '', '');
}

Cheers

1 Comment

how do i get the ?dest to the third page. can i do if (request.querystring('dest=') > 0){ window.open('/about.aspx', '', ''); } this is because i need to get the querystring from the previous page to this page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.