那麼,你可以使用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