0
好吧我在我的網站上進行了表單搜索,點擊時將搜索結果加載到顯示的隱藏iframe中。這是IFRAME:一個腳本,告訴別人一旦點擊它之外的任何內容
<iframe class="slidingDiv" id="frame-content-left2" name="search-box"
src="content.html"></iframe>
這是切換顯示它的開/關狀態的按鈕:
<input type="submit" value="Search" class="send-button" />
現在,當上面的iframe中顯示了網頁內容的DIV,該網站的導航鏈接加載到消失。這是div:
<div id="myDiv">some content here</div>
現在我有一點問題,因爲當我點擊左側導航中你不能看到它加載到,因爲它是隱藏在div。我想是以某種方式告訴與搜索結果的iframe消失,一旦我點擊的東西在它之外,像一個鏈接或空白區域,使得這個div:
<div id="myDiv">some content here</div>
出現。
這是我使用的代碼:
<script type="text/javascript">
$(document).ready(function() {
$('.send-button').click(function() {
if ($('#frame-content-left2').is(':visible')) {
$('#frame-content-left2').hide(2000);
$('#myDiv').show(2000);
}
else {
$('#frame-content-left2').show(2000);
$('#myDiv').hide(2000);
}
});
});
我現在試一試,讓你知道發生了什麼... – spencer
它部分工作。我想出現的div(myDiv)出現,但iframe不會消失。當目標(width id =「myDiv」)出現時,我希望帶搜索結果的iframe消失。 – spencer
你有框架。去修改它,讓你有你想要的功能。添加一行來隱藏iframe,並且你有你需要的。 – tkone