javascript窗口重定向在chrome中不起作用((取消) - 状态) [英] javascript window redirect doesn't work in chrome ((canceled) - status )

查看:186
本文介绍了javascript窗口重定向在chrome中不起作用((取消) - 状态)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用下面的代码进行重定向:

 < script type =text / javascript > 
window.location.href =http://google.com
< / script>

FF和IE正常工作。 Chrome没有。

以上要求 http://google.com ,在Chrome浏览器>开发工具>网络中获得取消状态。



我尝试了其他几个功能:

  location.href = url 
location.replace(url)
document.location = url
location.assign(url)
window.open(url,'_self')

在本地html文件中粘贴相同的代码可以正常工作。



以下是重定向请求,它被chrome取消: http://pastebin.com/hD36M1RG



任何线索?
Thanks

解决方案

尽量不要使用窗口。在我的情况。我已经使用 location.assign()而不是 window.location.assign()并工作。


I'm trying to do a redirect using the below code:

<script  type="text/javascript">
window.location.href = "http://google.com"
</script>

FF and IE work as they should. Chrome doesn't.

The request above to http://google.com, gets a 'canceled' status in Chrome browser > Development tools > "Network".

I've tried several other functions:

location.href = url
location.replace(url)
document.location = url
location.assign(url)
window.open(url, '_self')

Same code pasted within a local html file works fine.

Below is the redirect request that it's canceled by chrome: http://pastebin.com/hD36M1RG

Any clues? Thanks

解决方案

Try without window., it helped in my case. I had used location.assign() instead of window.location.assign() and worked.

这篇关于javascript窗口重定向在chrome中不起作用((取消) - 状态)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆