简体   繁体   English

iFrame重新加载帧而不是页面

[英]iFrame reload frame not page

here is my code, I'm not sure how to reload the iFrame page(switch pages when the next/previous button is clicked) and not the whole page making their scroll bar set back to the top of the page, my users are finding it very annoying. 这是我的代码,我不知道如何重新加载iFrame页面(单击下一个/上一个按钮时切换页面)而不是整个页面使他们的滚动条设置回页面顶部,我的用户正在查找这很烦人。

    <style>
p {
font-size:16pt;
font-color:cyan;
background-color:orange;
border-style:solid;
border-color:black;
border-width:3px;
width:128px;
vertical-align:middle;
horizontal-align:middle;
margin-left: auto;
margin-right: auto;
text-align:center;
}
</style>


<script type="text/javascript">
flag = 0;
SrcList = new Array("http://www.minecraft-index.com/3864-clearrealms/vote", "http://minecraft-mp.com/server/34632/vote/", "https://minestatus.net/98330-clearrealms/vote", "http://topminecraftservers.org/vote/19", "http://topg.org/Minecraft/in-378224#.Uu1YmHddWwE", "http://minecraft-server-list.com/server/197826/vote/", "http://www.planetminecraft.com/server/clearrealms-2643064/vote/");
function NextSrc(){
    if(flag < SrcList.length - 1){
    flag++;
    ChangeSrc(SrcList[flag]);
    }
    return false;
}
function PrevSrc(){
    if(flag > 0){
    flag--;
    ChangeSrc(SrcList[flag]);
    }
    return false;

}
function ChangeSrc(src){
    var iframe = document.getElementById('Vote');
    iframe.setAttribute('src',src);
}
</script>

<p><a href="#" onclick="PrevSrc()">Prev</a>  -  <a href="#" onclick="NextSrc()">Next</a></p>
<iframe id="Vote" src="http://minecraftservers.org/vote/96178" width="1080" height="795">
</iframe>  

well i think that you might be looking for this: 好吧,我认为你可能正在寻找这个:

document.getElementById('Vote').contentWindow.location.reload(true);

true paramete = Reloads the page from the server. true paramete =从服务器重新加载页面。 false parameter = Reloads the page from the browser cache. false参数=从浏览器缓存重新加载页面。 so this isn't what you want. 所以这不是你想要的。

try this one instead in the 试试这个而不是

<head></head>

tags. 标签。

function Reload() {
var iframe = document.getElementById('Vote');
iframe.src = iframe.src;
}

and the html code like this: 和这样的HTML代码:

<p><a href="#" onclick="PrevSrc()">Prev</a> - <a href="#" onclick="Reload()">Reload</a>  -  <a href="#" onclick="NextSrc()">Next</a></p>
<iframe id="Vote" src="http://minecraftservers.org/vote/96178" width="1080" height="795">

Thanks for the link. 谢谢你的链接。 Change the link's href from # to javascript:void(0); 将链接的href#更改为javascript:void(0); so like 所以喜欢

<p>
<a href="javascript:void(0);" onclick="PrevSrc()">Prev</a>
  -  
<a href="javascript:void(0);" onclick="NextSrc()">Next</a>
</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM