2014-02-15 27 views
0

我可以通過iframe中顯示我的其他網頁,但我怎麼能使其不可見或者當同一按鈕被再次點擊如果再次單擊相同的按鈕或單擊其他按鈕,如何隱藏Iframe?

<html> 
<script type="text/javascript"> 
function showIFrame() { 
    var iframe = document.getElementById("myiframe"); 
iframe.style.display="block"; 
} 
</script> 
<style> 
#myiframe { 
display:none; } 
</style> 
<body> 
<iframe id="myframe" name="carsearch" width="535" height="625" scrolling="no" frameborder="0"></iframe> 
<form name="search" id="search" method="get" action="../crime_map/map_crime_pending.php" target="carsearch"> 

<button type="submit" id="SearchCarButton" class="submitBtn" onclick="showIFrame()"/> <span>Search</span></button></form> 
<button>Catcher</button> 
</body> 
</html> 
+0

這個http://api.jquery.com/toggle/不起作用? – zamil

回答

0

試試這個代碼,檢查顯示終止該網頁,並改變它設在當前狀態;

function showIFrame() { 
     var iframe = document.getElementById("myiframe"); 
     var d = iframe.style.display; 
     if(d=="block"){ 
     iframe.style.display = "none" 
     }else{ 
     iframe.style.display = "block"; 
     } 
} 
相關問題