window.location 在 safari 上调用弹出空对话框

发布于 2024-08-29 22:30:13 字数 327 浏览 4 评论 0原文

在网页上,我试图将浏览器重定向到同一站点上的另一个页面。 代码非常简单:

window.location = "/path1/path2"

在 safari 上 - 无论是 Windows 还是 Mac -

"http://domain.com"

都会出现一个仅包含文本的消息框。

我尝试了不同的方式来指定这一点:location.href、windows.assign(...) ...并且都具有相同的行为。

你们有人看到这个吗?你有解决办法吗?

谢谢。

on a web page i am trying to redirect the browser to another page on the same site.
the code is very simple for that:

window.location = "/path1/path2"

on safari - both windows as well as mac - a message box containing only the text

"http://domain.com"

comes up.

I have tried different ways of specifying this: location.href, windows.assign(...) ... and the all have the same behavior.

Did any of you see this? and do you have a solution for this?

Thanks.

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

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

发布评论

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

评论(3

一直在等你来 2024-09-05 22:30:13

看看这个问题。你应该使用:

location.href = 'url';

take a look at this question. You should use:

location.href = 'url';
奈何桥上唱咆哮 2024-09-05 22:30:13

感谢大家的帮助。

我发现了问题。在调用链中某处设置 window.location 之前,一个函数会发出 ajax 请求。

看来由于一些变化,请求现在比以前需要更长的时间。因此,如果在 ajax 请求期间更改位置,则会出现空消息框。

梅米。

thanks all for you help.

i found the problem. Before setting window.location somewhere in the call chain one function would make an ajax request.

It seem that due to some changes the request now takes longer then before. So if the location was changed during the ajax req., the empty message box would appear.

Memi.

林空鹿饮溪 2024-09-05 22:30:13

你应该展示完整的代码。
例如,此错误代码

<a href="javascript:window.open()">Click</a>

在单击时将显示 [OBJECT]。

如果你的脚本正好是

<script>
window.location='someurl';
</script>

这样,那么还有其他事情发生 - 我刚刚在我的 Mac 上的 Safari 中测试了这个

<script>
window.location='http://www.google.com'
</script>

you should show the complete code.
For example THIS bad code

<a href="javascript:window.open()">Click</a>

will show [OBJECT] when clicked.

If your script is just

<script>
window.location='someurl';
</script>

then there is something else going on - I have just test this in Safari on my Mac

<script>
window.location='http://www.google.com'
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文