2011-03-21 105 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設置爲空,例如, - '