hisotry html标签,HTML DOM History go()用法及代码示例

HTML中的History go()方法用于从历史记录列表中加载特定的URL。如果已知要从历史记录中加载的特定页面的数字或URL,则它是history.back()和history.forward()方法的更好替代。

用法:

history.go( number|URL )

参数:此方法接受单个参数number | URL,该参数是必需的,用于指定历史记录列表中URL的编号/位置或页面的URL。 -1用于向后翻一页,而1用于向后翻一页。

下面的程序演示了HTML中的History go()方法:

例:

DOM History.go() Method

h1 {

color:green;

}

h2 {

font-family:Impact;

}

body {

text-align:center;

}

GeeksforGeeks

DOM History.go( ) Method

For going to the second next URL in the

history, double click the "Go to the

second next URL" button:

Go to the second next URL

function history_goforward() {

window.history.go(2);

}

输出:

ff68def5fd92080d5bd02c123f435765.png

范例2:用于转到历史记录列表中的上一个URL。

DOM History.go() Method

h1 {

color:green;

}

h2 {

font-family:Impact;

}

body {

text-align:center;

}

GeeksforGeeks

DOM History.go() Method

For going to the previous URL in the

history, double click the "Go to the

previous URL" button:

Go to the previous URL

function history_goback() {

window.history.go(-1);

}

输出:

4db5ebb17398f892c2a34542f95f7ea3.png

支持的浏览器:下面列出了History back()方法支持的浏览器:

谷歌浏览器

IE浏览器

火狐浏览器

Opera

苹果浏览器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值