使用Javascript Window.open(Using Javascript Window.open)

编程入门 行业动态 更新时间:2024-10-27 11:20:53
使用Javascript Window.open(Using Javascript Window.open)

我正在尝试编码,以便我使用Javascript使用window.open打开一个网址。 这会根据需要打开一个新窗口,但网址错误。 它将域url添加到它的开头。 有谁知道我会如何解决这个问题? 它必须使用JavaScript。

&TeledoccLogo = "<a onclick=""javascript:window.open('www.teladocc.com/');iAddClickStat('Benefits_Teladocc_Link');return false;"" href='#'>

我需要的网址: https : //finder-t2.int.ps.nbc.com/psp/ps/EMPLOYEE/EMPL/h/www.teladocc.com/pnc

I am trying to code so that I use Javascript using window.open to open a url. This opens a new window as desired, BUT the url is wrong. It adds the domain url to the beginning of it. Does anyone know how I would fix this? It has to use javascript.

&TeledoccLogo = "<a onclick=""javascript:window.open('www.teladocc.com/');iAddClickStat('Benefits_Teladocc_Link');return false;"" href='#'>

URL it takes me to: https://finder-t2.int.ps.nbc.com/psp/ps/EMPLOYEE/EMPL/h/www.teladocc.com/pnc

最满意答案

那是因为这不是一个完整的URL:

www.teladocc.com

这是一个相对的 URL。 浏览器无法知道www.teladocc.com与index.html之间的区别。

如果你这样做:

window.open('index.html')

然后你真的不希望去http://index.html ,对吗?

使用完全限定的URL:

window.open('http://www.teladocc.com/pnc')

That's because this isn't a full URL:

www.teladocc.com

It's a relative URL. The browser has no way of knowing the difference between www.teladocc.com and, say, index.html.

If you did this:

window.open('index.html')

Then you wouldn't really expect to go to http://index.html, would you?

Use a fully-qualified URL:

window.open('http://www.teladocc.com/pnc')

更多推荐

本文发布于:2023-07-31 00:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340425.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Javascript   Window   open

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!