sinaw
sinaw

Reputation: 4203

javascript code not working

<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.

Upvotes: 0

Views: 1131

Answers (3)

Torez
Torez

Reputation: 1912

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

Upvotes: 0

fil maj
fil maj

Reputation: 2312

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> 

Upvotes: 2

Aaron
Aaron

Reputation: 7098

Change the window.open line to

window.location = '/about.aspx';

Include the semicolon, which is missing in your code.

Upvotes: 0

Related Questions