Firefox 中的 window.location onload

发布于 2024-09-24 16:08:34 字数 355 浏览 3 评论 0原文

对于每个人来说可能都是一个简单的问题。这会在 Chrome 和 Safari 中显示带有位置的警报,但在 Firefox 中

<html> 
<head> 
<script type="text/javascript"> 
function onload() {
var loc = window.location;
alert("url is " +loc);
return false;
}
</script> 
</head> 
<body onload="onload()"> 
</body> 
</html> 

不起作用

Probably a simple question for everyone. This displays the alert with the location in Chrome and Safari but it doesn't work in Firefox

<html> 
<head> 
<script type="text/javascript"> 
function onload() {
var loc = window.location;
alert("url is " +loc);
return false;
}
</script> 
</head> 
<body onload="onload()"> 
</body> 
</html> 

Any Ideas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望喜 2024-10-01 16:08:34

不要使用像 onload 这样的名称。

<html> 
<head> 
<script type="text/javascript"> 
function loader() {
    var loc = window.location;
    alert("url is " +loc);
    return false;
}
</script> 
</head> 
<body onload="loader()"> 
</body> 
</html> 

Don't use names like onload.

<html> 
<head> 
<script type="text/javascript"> 
function loader() {
    var loc = window.location;
    alert("url is " +loc);
    return false;
}
</script> 
</head> 
<body onload="loader()"> 
</body> 
</html> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文