iframe的组织历史记录后退/前进 [英] histoy back/forward for iframe

查看:94
本文介绍了iframe的组织历史记录后退/前进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
我的网页上有一个iframe.我正在iframe上动态显示不同的页面.
现在我只想为iframe内容实现后退/前进按钮.
我该怎么办?
谢谢

Hi..
i have an iframe on my web page. i am displaying different pages dynamically on my iframe.
now i want to implement back/forward button for iframe contents only.
how should i do this?
thanks

推荐答案

我们已经讨论了
We have discussed this earlier[^], haven''t we?

Once again, in order to implement a back/forward button, you need to keep a track of all the URL''s in sequence. It would be kind of a URL stack. Now, have two buttons. Back would traverse you to previous URL from current and forward would take you to next one.

Now, please give it a try! I don''t see why or what''s unclear here and stopping you.


var urlList = new Array();
var pos = 0;
function goToPage(pageUrl)
{
    urlList[urlList.length] = pageUrl;
    pos = urlList.length - 1;
    document.getElementById('iframe').src = pageUrl;
}
function goBack()
{
    if (pos > 0)
    {
        pos--;
        document.getElementById('iframe').src = urlList[pos];
    }
    else
        alert('You reached the first page of history');

}
function goForward()
{
    if (pos < (urlList.length-1))
    {
        pos++;
        document.getElementById('iframe').src = urlList[pos];
    }
    else
        alert('You reached the last page of history');
}



使用功能goToPage(pageUrl)可以在iframe中导航页面,使用goBack功能可以向后导航,而goForward功能可以向前导航.



Use the function goToPage(pageUrl) to navigate the page in iframe, goBack function to navigate back and goForward function to navigate forward.


这篇关于iframe的组织历史记录后退/前进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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