2011-03-21 106 views
1

在我的页面上我有2个iframe。onload不加载iframe jquery

我有一个函数来重新加载iframe的点击。

现在我想加载主页面而不加载2 iframe。 这可能吗?我会怎么做?

<ul> 
      <li><a href="#discotheque">Discoth&egrave;que</a> 
      </li> 
      <li><a href="#articlesPresse">Articles de presse</a></li> 
    </ul> 

    <div id="discotheque"> 
<a href="javascript: void(0)" onclick="discothequeReload();" style="text-decoration: none" class="">Nouvelle recherche</a> 
    <script type="text/javascript"> 

    function discothequeReload() { 
    var f = document.getElementById('discothequeReload'); 
    f.src = f.src; 
    } 
    </script> 

       <!--TEST RELOAD--> 
     <iframe id="discothequeReload" frameborder="0" src="http://www.google.com"> 
     </iframe> 


    </div> 


    <div id="articlesPresse"> 
     Articles de presse 
       <a href="javascript: void(0)" onclick="articlesPresseReload();" style="text-decoration: none" class="">Nouvelle recherche</a> 
<script type="text/javascript"> 

function articlesPresseReload() { 
var f = document.getElementById('articlesPresseReload'); 
f.src = f.src; 
} 
</script> 
      <!--TEST RELOAD--> 
     <iframe id="articlesPresseReload" frameborder="0" src="http://www.yahoo.com"> 
     </iframe> 
    </div> 

回答

1

加载页面和负荷,iframe后您的链接,在用户点击?好的,当用户点击时放入iframe html。我认为它的工作......我记得几个月前我做了这样的事情,就像这个 。

<a href="#" onclick="discothequeReload();" style="text-decoration: none" class="">Nouvelle recherche</a> 

<div id="discotheque"> 
<!-- without the ifram --> 
</div> 

<script> 
function discothequeReload() { 
    $("#discotheque").html('<iframe id="discothequeReload" frameborder="0" src="http://www.google.com"></iframe>'); 
} 
</script> 
+0

不错!正是我期待的! – user472285 2011-03-21 16:53:14

0

如果你的意思是你想从你的网页的iframe的位置重定向...

document.location = $("#articlesPresseReload")[0].src; 
+0

我的问题是如何加载我的主页面而无需加载2个iframe。 – user472285 2011-03-21 15:56:23

+0

哦。唯一的解决方法是以某种方式使它们失效 - 将src设置为空,例如, - '