[英]Redirect from one html page to another page using jquery
I have created 2 static html pages locally, demo1.html
and demo2.html
. 我在本地创建了2个静态html页面demo1.html
和demo2.html
。
I need to redirect from one page to another pag. 我需要从一页重定向到另一页。 Initially I opened my demo1.html
page (url is file:///D:/app/demo1.html). 最初,我打开了demo1.html
页面(URL为file:/// D:/app/demo1.html)。
Now on clicking a button in this page I want to redirect to demo2.html
现在单击此页面上的一个按钮,我想重定向到demo2.html
I tried: 我试过了:
$( "#submit" ).click(function() {
window.location.href = "/demo2.html";
});
but it did not work. 但它没有用。 What changes I need to make it to work? 我需要进行哪些更改才能使其正常工作?
Drop the / at the begining of your new url. 在新网址的开头删除/。
If you are loading from a file like you said, writing "/demo2.html"
will map to file:///d:/demo2.html
如果要从您说的文件中加载文件,则写入"/demo2.html"
将映射到file:///d:/demo2.html
If you write 如果你写
$( "#submit" ).click(function() {
window.location.href = "demo2.html";
});
This will map to the same folder where you started your app, that is file:///D:/app/demo2.html
这将映射到您启动应用程序的同一文件夹,即file:///D:/app/demo2.html
Try this 尝试这个
$('#submit').click(function() {
window.location = '/demo2.html';
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.