javascript 无法在 iPad 上使用 window.location
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16714578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Use of window.location doesn't work on iPad
提问by LDJ
I'm using some JavaScript
that will redirect the user to another URL
after a fixed period of time. This is working well on all browsers but on an iPad 3 I have to test on it isn't working. The timeout fires and I call
我正在使用一些JavaScript
将用户重定向到另一个URL
固定时间段后。这在所有浏览器上运行良好,但在 iPad 3 上我必须测试它不起作用。超时触发,我打电话
window.location = "www.someurl.com";
and I've also tried
我也试过
window.location.href = "www.someurl.com";
I can see the URL
in the browser changing to www.someurl.ocom
but the browser doesn't actually go there - it stays on the same page.
我可以看到URL
浏览器中的 更改为 ,www.someurl.ocom
但浏览器实际上并没有转到那里 - 它停留在同一页面上。
Is there something iPad specific I have to do to make this work?
有什么特定于 iPad 的我必须做的事情吗?
Thanks
谢谢
回答by Sagish
try
location.href = "..."
, should work on both
尝试
location.href = "..."
,应该对两者都有效
回答by Jason
The right answer here is you are missing the protocol.
window.location.href = "http://www.someurl.com";
should do the trick
这里的正确答案是您缺少协议。
window.location.href = "http://www.someurl.com";
应该做的伎俩