window.location call popup up empty dialog on safari

南楼画角 提交于 2019-12-25 04:51:59

问题


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.


回答1:


take a look at this question. You should use:

location.href = 'url';



回答2:


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.




回答3:


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>


来源:https://stackoverflow.com/questions/2685958/window-location-call-popup-up-empty-dialog-on-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!