top.location.href 不起作用 @ Opera



我正在使用这个小导航代码片段

<script type="text/javascript">
if(document.location.href.indexOf('.99')>-1)
{
  top.location.href = "http://bit.ly/xxx";
}
else
{
  top.location.href = "http://bit.ly/yyyy";
}
</script>

我的服务器上有 2 个 IP,如果它的 .98 我想导航到 XXX,如果不是 yyyy

很简单,因为它适用于所有浏览器,而不是 Opera。

在歌剧中,只有 else { } 部分有效。

如果你想看演示

只需转到该链接:http://pastebin.com/raw.php?i=qEyzcG3W

试试这个:

top.location.href = 'http://bit.ly/' + 
                    ( location.href.indexOf( '.99' ) > -1 ? 'xxx' : 'yyy' );

您正在访问document.location对象,而不是全局location对象。

最新更新