當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


SVG window.menubar屬性用法及代碼示例

SVG window.menubar屬性返回菜單欄對象,通過它我們可以檢查可見性。

用法:

var mb = window.menubar

返回值:該屬性返回菜單欄對象。

範例1:

HTML



<!DOCTYPE html> 
<html> 
  
<body> 
    <center> 
        <h1>GeeksforGeeks</h1> 
  
        <button onclick="get()"> 
            Click Here 
        </button> 
          
        <svg viewBox="0 0 10000 10000" 
            xmlns="http://www.w3.org/2000/svg"> 
              
            <script type="text/javascript"> 
                function get() { 
                    var g = document.getElementById("g"); 
                    console.log(window.menubar); 
                } 
            </script> 
        </svg> 
    </center> 
</body> 
  
</html>

輸出:

範例2:

HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <center> 
        <h1>GeeksforGeeks</h1> 
  
        <button onclick="get()"> 
            Click Here  
        </button> 
          
        <div id="g"></div> 
          
        <svg viewBox="0 0 1000 1000" 
            xmlns="http://www.w3.org/2000/svg"> 
              
            <script type="text/javascript"> 
                function get() { 
                    var g = document.getElementById("g"); 
                    g.innerHTML = "Is it visible?:" 
                        + window.menubar.visible; 
                } 
            </script> 
        </svg> 
    </center> 
</body> 
  
</html>

輸出:

支持的瀏覽器:

  • 穀歌瀏覽器
  • Edge
  • Firefox
  • Safari
  • Opera
  • IE瀏覽器




相關用法


注:本文由純淨天空篩選整理自taran910大神的英文原創作品 SVG window.menubar Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。