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


HTML Window status用法及代碼示例


HTML DOM中的Window status屬性用於在瀏覽器底部的狀態欄中設置或返回文本。

用法:

window.status

返回值:它返回一個字符串,代表狀態欄中顯示的文本。


範例1:本示例使用窗口狀態屬性。

<!DOCTYPE html> 
<html> 
  
<head> 
    <title> 
        HTML DOM Window status Property 
    </title> 
</head> 
  
<body> 
    <h1>GeeksforGeeks</h1> 
      
    <h2> 
        HTML DOM Window status Property 
    </h2> 
    <p> 
        Look the text in the statusbar displayed 
        at the bottom of the browser 
    </p> 
      
    <!-- Script to use window status property -->
    <script> 
        window.status = "GeeksforGeeks"; 
    </script> 
</body> 
  
</html>                                

輸出:

範例2:本示例使用窗口狀態屬性來設置狀態欄的文本。

<!DOCTYPE html> 
<html> 
  
<head> 
    <title> 
        HTML DOM Window status Property 
    </title> 
      
    <!-- Script to use window status property -->
    <script type="text/javascript"> 
        function UpdateStatusBar (over) { 
            if (over) 
                window.status = "The mouse is over the text."; 
            else 
                window.status = window.defaultStatus; 
        } 
  
        function ChangeDefStatus () { 
            window.defaultStatus = "Default Status."; 
        } 
    </script> 
</head> 
  
<body> 
    <div onmousemove="UpdateStatusBar(true);" 
        onmouseout="UpdateStatusBar(false);"> 
        A message is seen on the status bar at the bottom 
        of the page when mouse is placed over the text 
    </div><br> 
  
    <button onclick="ChangeDefStatus();"> 
        Change default status 
    </button> 
      
    <br><br> 
      
    <a href="#"> 
        When mouse move over, the browser 
        will display the URL 
    </a> 
</body> 
  
</html>                    

輸出:

支持的瀏覽器:DOM窗口狀態屬性不支持任何瀏覽器。



相關用法


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