Javascript 如何不使window.location相对于文件
我不知道为什么我找不到发生这种情况的原因或如何修复它,但以下是我的代码:Javascript 如何不使window.location相对于文件,javascript,html,window.location,Javascript,Html,Window.location,我不知道为什么我找不到发生这种情况的原因或如何修复它,但以下是我的代码: window.location.href=(“www.google.com”)指定http://协议,否则它将尝试启动相对于页面url的路径。您也可以只使用window.location window.location = 'http://www.google.com'; 在不指定协议的情况下,它就像基于当前URL的相对链接 与此情况非常相似: var-anchors=document.getElementsByTa
window.location.href=(“www.google.com”)代码>指定http://
协议,否则它将尝试启动相对于页面url的路径。您也可以只使用window.location
window.location = 'http://www.google.com';
在不指定协议的情况下,它就像基于当前URL的相对链接
与此情况非常相似:
var-anchors=document.getElementsByTagName('a');
对于(var i=0;i';
}
对于完全绝对的URL,您需要从协议(http://
)开始,对于域相对URL,则需要从协议开始。就其本身而言,www.google.com
仅作为一个完全相对的URL有效。谢谢