[英]How Can I go to another HTML file
For some reason, document.location.href
, window.location.href
, and window.location.replace
is not working, I'm using localhost for now and I don't know how to redirect it to another webpage.出于某种原因,
document.location.href
、 window.location.href
和window.location.replace
无法正常工作,我现在使用的是 localhost,我不知道如何将其重定向到另一个网页。 I tried adding http:// on front, it's still not working, I tried making it redirect to another online website, It also didn't work.我尝试在前面添加 http:// ,它仍然无法正常工作,我尝试将其重定向到另一个在线网站,它也没有工作。 I read a lot of thread already and tried them but none of them worked for me.
我已经阅读了很多线程并尝试了它们,但它们都不适合我。
var loginBut = document.getElementById("RDbtn1");
loginBut.addEventListener("click", checklogin);
function check(){
document.location.href = "http://localhost/some/directory/here";
alert(document.location.origin + '/some/directory'); // I just use this to know that the button is being pressed.
}
html: html:
<!-- some code here-->
<li><button class="login1" id="RDbtn1">LOGIN</button></li>
<!-- some code here -->
I believe you should redirect to particular html page and should give the port on which your local host application is working我相信您应该重定向到特定的 html 页面,并且应该提供本地主机应用程序正在运行的端口
document.location.href = "http://localhost:8080/some/directory/here/file.html";
What's the difference between window.location and document.location in JavaScript? JavaScript 中的 window.location 和 document.location 有什么区别?
window.location = "/some/directory/here/index.html"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.