❶ 在java web开发中,凡是能实现页面跳转的方法有哪些具体列出这些方法的实现语句
一、跳转到新页面,并且是在新窗口中打开页面:
function openHtml()
{
//do someghing here...
window.open("xxxx.html");
}
window是一个javascript对象,可以用它的open方法,需要注意的是,如果这个页面不是一相相对路径,那么要加“http://”,比如:
function openHtml()
{
window.open("http://www..com");
}
二、在本页面窗口中跳转:
function totest2()
{
window.location.assign("test2.html");
}
如果直接使用location.assgin()也可以,但是window.location.assign()更合理一些,当前窗口的location对象的assign()方法。
另外,location对象还有一个方法replace()也可以做页面跳转,它跟assign()方法的区别在于:
replace() 方法不会在 History 对象中生成一个新的纪录。当使用该方法时,新的 URL 将覆盖 History 对象中的当前纪录。