我正在尝试编码,以便我使用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.comIt'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')更多推荐
发布评论