2012-10-14 69 views
2

我有一個腳本,它將在加載iframe的內容時顯示加載文本。 我第一次打開頁面時,它會完美地工作。 但這個頁面我有一個將在iframe中啓動鏈接,並加載文本上不顯示這些鏈接:(在iframe加載時加載文本

這裏見例如: http://www.ndnm.co.cc/test.php

它會工作的第一次加載頁面,但如果你點擊「測試環節」加載文本將不會顯示:(

注:iframe中加載外部域

我怎樣才能修復

?個

非常感謝

+0

所以問題是,在點擊鏈接後加載iframe中的頁面時,「加載消息」不顯示? – ted

回答

5

你可以嘗試把一間點擊鏈接事件,所以一切有人點擊它,像「頁面加載...」將被顯示,並已在牆根 - 有「hideProgress()」函數。

喜歡的東西:

<a href="http://www.perdu.com" target="iframe" onClick="document.getElementById('loader').style.display = 'block';">TEST LINK</a><br> 

事情是這樣的:http://jsfiddle.net/SFjS2/(記住,第二個頁面加載速度非常快,所以「頁面加載」的形象不會被看到easily..try把一些更多的東西有:P)

+1

太棒了!它工作完美!非常感謝 – anarchOi

1

我打算給你一個jquery解決方案,就像你這樣標記它。

解決方案代碼位於http://jsfiddle.net/nPWAp/1/然而HTML是

<body> 
<div> 
    <a href="#" id="testlink">TEST LINK</a> 
</div> 
<iframe id="frame"></iframe> 
<div id="statement"></div> 
</body> 

和jQuery是

$(document).ready(function() { 
    $("#testlink").click(function() { 
     // --- set statement -- 
     $("#statement").show(); // show the div in case it was hidden.  
     $("#statement").text("Loading content..."); // replace the text 
     $("#statement").hide(5000); // hide after 5 seconds 

     // --- Scrape content --- //   
     $("#frame").attr('src', "http://www.test.com"); 
    }); 
}); 

添加CSS

#frame{ 
wdith: 100% 
height: 50em; 
border: 1px solid #ccc; 
} 

的破折號,它都應該發出咕嚕聲。顯然,你會想看看jQuery的一些更好玩的選項。

HTH