【发布时间】:2021-12-22 08:08:06
【问题描述】:
我正在尝试制作一个涉及重定向到另一个网站的项目。我在这样做时遇到了麻烦。
这是我的代码
document.getElementById("ContinueToWeb").onclick = function () {
location.href = "google.com";
}
<html>
<head>
<!--Some code here-->
</head>
<body>
<!--Some code here-->
<button id="ContinueToWeb">Continue</button>
</body>
</html>
由于某种原因,它从c:/folder/index.html 重定向到c:/folder/google.com,即使我告诉它从c:/folder/index.html 到google.com。你知道发生了什么吗?
【问题讨论】:
-
把网址改成
https://google.com -
如果你告诉它转到
index2.html,你会希望它转到http://index2.html吗? -
是的,我希望它会转到HTTP://index2.html
标签: javascript html