开发者

javascript code not working

开发者 https://www.devze.com 2022-12-17 01:30 出处:网络
<script language=\"JavaScript\" type=\"text/javascript\"> if (location.href.indexOf(\'?dest=\') > 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.


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> 


Change the window.open line to

window.location = '/about.aspx';

Include the semicolon, which is missing in your code.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号