如何在加载后强制重新加载iFrame [英] How to force an iFrame to reload once it loads

查看:1414
本文介绍了如何在加载后强制重新加载iFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多iframe加载我的网页上的特定内容。父母和iframe在同一个域上。

我在iframe中有一个滚动条,它似乎无法在所有浏览器中正确加载。但是当我刷新iframe时,它会加载完美。我不知道为什么这样做。

我使用了元刷新,这种方法可行,但我不希望页面不断刷新,只需要一次。

我正在寻找的解决方案将在打开iFrame后重新加载iFrame内容,延迟时间最短。



感谢您的时间和帮助!

-Brett

----------编辑:--------



我意识到当我的页面加载所有的iframe时该索引被加载。 iframes出现在一个jQuery覆盖中,它也被加载,但可见性:隐藏直到被调用。所以在这个电话会议上,当我想要重新加载iframe。

任何人都可以帮我想出一个Javascript函数,当我点击链接到iFrame时,它会重新载入iFrame?我已经接近了,但是我对js一无所知,并且我一直处于短缺状态。我有一个重新加载页面的功能,但我无法弄清楚如何只调用一次。

我到目前为止:

 < script type = 文本/ JavaScript的 > 

var pl;
var change;
pl = 1;

函数ifr(){

if(pl = 1){
document.location.reload([true]);
alert(Page Reloaded!);
change = 1;
回报变化;
}

变更+ pl;

$ b



所以基本上它使用document.location.reload来重新加载页面。我试图然后使pl改变为1以外的东西,所以函数不会再运行。我一直在用onLoad调用这个JS。

解决方案

所有这些线索都已经死了,但我找到了一个有效的代码片段。不是我写的,我不记得它是从哪里来的。

 < div class =overlay-content>只需发帖即可帮助某人应该有同样的问题。 // CSS所需的内容容器样式



< div id =Reloader> // iFrame将被重新加载到这个div中

< / div>



//在页面载入
时脚本重新载入iframe< script>
函数aboutReload(){
$(#Reloader)。html('< iframe id =Reloaderheight =355pxwidth =830pxscrolling =noframeborder = 0src =about.html>< / iframe>');
}
< / script>



< / div>

基本上只是在带有iFrame的窗口打开时加载iFrame源代码,而不是在加载iFrame时原始页面加载。

I have numerous iframes that load specific content on my pages. Both the parent and iframe are on the same domain.

I have a scrollbar inside the iframe that doesn't seem to load correctly in all browsers. But when I refresh the iframe it loads perfect. I have no idea why it does this.

I have used the meta refresh, which works but I don't want the page to refresh constantly, just once.

The solution I'm looking for will reload the iFrame content after the iFrame is opened, with a minimal delay.

Thanks for your time and help!

-Brett

----------EDIT:--------

I realized that my page loads all of my iframes when the index is loaded. The iframes appear in a jQuery overlay, which is also loaded but visibility:hidden until called. So on this call is when I would want the iframe to be reloaded.

Could anyone help me come up with a Javascript function that reloads the iFrame when I click the link to the iFrame? I've gotten close but I know nothing about js and I keep falling short. I have a function that reloads the page, but I can't figure out how to get it called just once.

I have this so far:

<script type="text/javascript">

var pl;
var change;
pl=1;

function ifr() {

if (pl=1) {
    document.location.reload([true]);
    alert("Page Reloaded!");
    change=1;
    return change;
}

change+pl;

}

So basically it uses the document.location.reload which works to reload the page. I'm trying to then make pl change to something other than 1 so the function doesnt run again. I've been calling this JS from the body with onLoad.

解决方案

All the leads on this went dead, but I did find a code snippet that worked. Not written by me, and I don't remember where it came from. Just posting to help someone should they ever have the same question.

<div class="overlay-content"> //Content container needed for CSS Styling



     <div id="Reloader"> //iFrame will be reloaded into this div

     </div>



           //Script to reload the iframe when the page loads
         <script>
            function aboutReload() { 
              $("#Reloader").html('<iframe id="Reloader" height="355px" width="830px" scrolling="no" frameborder="0" src="about.html"></iframe>');
            }
         </script>



</div>

Basically just loads the iFrame source when the window with the iFrame opens, as opposed to the iFrame loading when the original page loads.

这篇关于如何在加载后强制重新加载iFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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