iframe 中的后退和前进按钮 [英] Back and forward buttons in an iframe

查看:19
本文介绍了iframe 中的后退和前进按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 JS 在 iframe 中实现"后退和前进按钮?

How to "implement" back and forward buttons in an iframe with JS?

推荐答案

使用 window.history 对象.

// For the current window
window.history.back();     
window.history.forward();

// For an iframe's window
iframe.contentWindow.history.back(); 
iframe.contentWindow.history.forward();

iframe.contentWindow.history.go(-1); // back
iframe.contentWindow.history.go(1);  // forward

https://developer.mozilla.org/en/dom/window.history

这篇关于iframe 中的后退和前进按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆