为iframe页面创建上一个下一个按钮 [英] create previous next button for iframe pages

查看:85
本文介绍了为iframe页面创建上一个下一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个主题可能有很多代码,但我似乎在寻找一个不基于历史的变体,是否可能......

This topic may have lots of code out there, BUT I seem to be looking for a variation that isn't based on history, is it possible...

所以我有这个代码......

So I have this code...

<script type="text/javascript">
var pages=new Array();

pages[0]="listItem1.html";
pages[1]="listItem2.html";
pages[2]="listItem3.html";
pages[3]="listItem4.html";
pages[4]="listItem5.html";

var i=0;
var end=pages.length;
end--;
function changeSrc(operation) {
if (operation=="next") {
if (i==end) {
  document.getElementById('the_iframe').src=pages[end];
  i=0;}
else {
  document.getElementById('the_iframe').src=pages[i];
  i++;}}
if (operation=="back") {
if (i==0) {
  document.getElementById('the_iframe').src=pages[0];
  i=end;}
else {
  document.getElementById('the_iframe').src=pages[i];
  i--;}}}
</script>
</head>

<body>

<ul id="menu" role="group">

<li><a href="listItem1.html" target="ifrm" role="treeitem">Welcome</a>
  <ul>
    <li><a href="listItem2.html" target="ifrm" role="treeitem">Ease of Access Center</a></li>
  </ul>
</li>    

<li><a href="listItem3.html" target="ifrm">Getting Started</a>
  <ul>      
    <li><a href="listItem4.html" target="ifrm">Considerations</a></li>
    <li><a href="listItem5.html" target="ifrm">Changing Perspective</a></li>
  </ul>
</li>
</ul>


<iframe id="the_iframe" scrolling="no" src="listItem1.htm" name="ifrm" style="width:540px;></iframe>


<input type="button" onClick="changeSrc('back');" value="Back" />
<input type="button" onClick="changeSrc('next');" value="Next" />

如果我点击下一个或上一个按钮,它确实会移动到某处,但是 ...

and if I click on the next or prev button, it does move somewhere,but...

让我说我的iframe显示listItem2,然后我点击菜单中的listItem4(有一个涉及的树菜单),然后我想去listItem3然后点击后退按钮...而不是去listItem3,它转到listItem2(或者某个不回来的地方)一个页面从4到3)。

let's say my iframe is showing listItem2, then I click on listItem4 in the menu (there is a tree menu involved), then I want to go to listItem3 and I hit the back button...instead of going to listItem3, it goes to listItem2 (or someplace that is not back a page from 4 to 3).

看来这些按钮是根据历史导航的?...但我只想要一个直线向前或向后移动......我不希望我的按钮具有此浏览器类型的功能...如果我在listItem4上并点击下一个按钮,我希望它转到listItem5。

It appears that the buttons are navigating based on history?...but I just want a straight forward or backward movement...I don't want my buttons to have this browser-type functionality...If I'm on listItem4 and hit the next button, I want it to go to listItem5.

非常感谢您的帮助!

推荐答案

好的,我会试试代码,但如果关闭则不降低它。

Okay, I'll try the code, but don't down-rate it if its off.

这是你可以放在changeSrc函数之前的函数:

This is the function that you could put before the changeSrc function:

功能UpdateI(){i = value}

function UpdateI(value) {i = value}

这一击您要添加到标记中的链接的事件。当然,在这种情况下发送函数的4将被更改为适用于任何ListItem被引用的任何内容:

This the one click event that you would add to your links in the a tag. Off course, the 4 that is sent the function in this case, would be changed to whatever is appropriate for whatever ListItem is being referenced:

onClick =UpdateI (4)

这对你有帮助吗?

这篇关于为iframe页面创建上一个下一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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