Window.open 只打开 url,不点击 - 点击必须手动完成 [英] Window.open only open url, does not click - click has to be done manually

查看:41
本文介绍了Window.open 只打开 url,不点击 - 点击必须手动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 window.open 并在单击时打开一个新窗口,预填充地址栏但不打开地址栏中填充的 url(对于 chrome)

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")

是不是我做错了什么.

推荐答案

您缺少协议(在您的示例中为 httphttps).

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

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

让浏览器知道您传递的是绝对 uri 还是相对 uri 很重要.如果它是绝对的(比如你的情况),你必须在协议前面加上.

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.

这篇关于Window.open 只打开 url,不点击 - 点击必须手动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆