javascript Firefox 中的 window.location.href
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4226133/
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
window.location.href in firefox
提问by Vishal Beri
Can you please tell me why window.location.hrefis not working on firefox?
你能告诉我为什么window.location.href不能在 Firefox 上工作吗?
Code:
代码:
<script>
function goToURL() {
window.location.href('url');
}
</script>
What can I use instead of window.location.hrefas an alternative?
我可以用什么来代替window.location.href?
回答by Justin Niessner
This should work in both IE and FireFox:
这应该适用于 IE 和 FireFox:
window.location.assign(url);
回答by Guffa
You use it for example like this:
例如,您可以像这样使用它:
window.location.href = 'http://www.guffa.com';
I have verified that this code works in Firefox 3.6.12.
我已验证此代码在 Firefox 3.6.12 中有效。
If that doesn't work for you, you have to be more specific in your question about what the exact problem is.
如果这对您不起作用,则您必须在问题中更具体地说明确切的问题是什么。
回答by Guffa
use it with an assignment
将其与作业一起使用
window.location = "http://...";
anyway you should be more specific in your question
无论如何你应该在你的问题中更具体

