Window.open only open url, does not click - click has to be done manually

独自空忆成欢 提交于 2019-12-25 17:18:35

问题


I'm using window.open and on click, it opens a new window, pre-fills the address bar but does not open the url filled in the address bar (for chrome)

window.open("www.stackoverflow.com","_blank")

Is there something that I'm doing wrong.


回答1:


You're missing the protocol (in your example http or https).

window.open("https://www.stackoverflow.com","_blank")

It's important for the browser to know if you're passing an absolute or relative uri. If it's absolute (like in your case), you have to prepend the protocol.



来源:https://stackoverflow.com/questions/37520996/window-open-only-open-url-does-not-click-click-has-to-be-done-manually

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