那么,你可以使用JavaScript来做到这一点。
当您按住点击事件时,您可以保存帧路径并在“刷新”时将此值添加到您的URL中,然后在您的iframe中选择此值并再次设置。我做了一个脚本,一起来看看:
var currentFramePath = '';
var iframe = '<iframe src="{src}" name="iframe_a" id="iframe_a "frameborder="0" width="100%" height="100"></iframe>';
$(document).ready(function(){
var urlFrame = getUrlParameter('currentFrame');
if(urlFrame != null && urlFrame != ''){
$('#iframeContainer').html(iframe.replace('{src}', urlFrame));
currentFramePath = urlFrame;
}
$('.button').click(function(){
currentFramePath = $(this).attr('href');
});
setInterval(function(){
window.location = window.location.href.split('?')[0] + '?currentFrame=' + currentFramePath;
}, 5000);
});
function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
HTML:
<div id='iframeContainer'>
<iframe src="Kine-Yield-Data/KG4x10.htm" name="iframe_a" id="iframe_a "frameborder="0" width="100%" height="100"></iframe>
</div>
<br>
<a href="Kine-Yield-Data/KG4x10.htm" target="iframe_a" class="button">10</a>
<a href="Kine-Yield-Data/KG4x25.htm" target="iframe_a" class="button">25</a>
<a href="Kine-Yield-Data/KG4x30.htm" target="iframe_a" class="button">30</a>
<a href="Kine-Yield-Data/KG4x50.htm" target="iframe_a" class="button">50</a>
编辑:
谷歌浏览器不允许你改变IFRAME SRC属性,因此,一我发现这样做的方法是用新的SRC值重新创建元素。
我希望它能帮助你。
它有趣的是,谷歌搜索只发现人们问我想要的相反。我猜想我很难过! – Jamsandwich