Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何不使window.location相对于文件_Javascript_Html_Window.location - Fatal编程技术网

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有效。谢谢