用javascript作訊息提示框(類似於QQ使用者上線的訊息提示)

來源:互聯網
上載者:User
javascript

在開發項目的時候,需要在有使用者訊息的時候提醒使用者,剛好自己的QQ好友上線,QQ自動彈出一個訊息提示,覺得不錯。所以用javascript利用popup作了一個類似的功能。

<html>
 <head>
  <title>HTMLPage1</title>
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
  <meta name="ProgId" content="VisualStudio.HTML">
  <meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
 </head>
 
 <script language =javascript>
   var titlePopup
   var len;
   
   function InitMsgBox()
   { len = 0;
    titlePopup=window.createPopup();
    var titlePopupBody = titlePopup.document.body;
    titlePopupBody.style.border ="solid black 1px";
    var titleContent = "";
    titleContent = titleContent + "<table cellPadding='5' bgcolor='#65c1ff' width='100%' height='100%' border=0 cellspacing=0 cellpadding=0>";
    titleContent = titleContent + "<tr><td align=center><font size = 2>訊息提醒</font></td></tr>";
    titleContent = titleContent + "<tr><td><font size = 2>內容</td></font></tr>";
    titleContent = titleContent + "<tr><td><font size = 2>內容</td></font></tr>";
    titleContent = titleContent + "<tr><td><font size = 2>日期</td></font></tr>";
    titleContent = titleContent + "</table>";    
    titlePopupBody.innerHTML = titleContent;
         
    ShowMsgBox();
   }
      
   function MsgBox()
   { 
    len += 4;      
    if (len > 110)
    {   
     window.clearInterval(tID);     
    }        
    else
    {//170固定了訊息提示框的寬度
     titlePopup.show(document.body.clientWidth - 170, document.body.clientHeight - len, 170, len, top.document.body); 
    }    
   }
   
   var tID
   function ShowMsgBox()
   {
    tID = window.setInterval("MsgBox()",15);    
   }
 </script>
 
 <body MS_POSITIONING="GridLayout">
  <INPUT id="Button1" style="Z-INDEX: 101; LEFT: 296px; POSITION: absolute; TOP: 344px" type="button"
   value="Button" name="Button1">
 </body>
</html>

<html> <head> <title>HTMLPage1</title> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="ProgId" content="VisualStudio.HTML"> <meta name="Originator" content="Microsoft Visual Studio .NET 7.1"> </head> <script language =javascript> var titlePopup var len; function InitMsgBox() { len = 0; titlePopup=window.createPopup(); var titlePopupBody = titlePopup.document.body; titlePopupBody.style.border ="solid black 1px"; var titleContent = ""; titleContent = titleContent + "<table cellPadding='5' bgcolor='#65c1ff' width='100%' height='100%' border=0 cellspacing=0 cellpadding=0>"; titleContent = titleContent + "<tr><td align=center><font size = 2>訊息提醒</font></td></tr>"; titleContent = titleContent + "<tr><td><font size = 2>內容</td></font></tr>"; titleContent = titleContent + "<tr><td><font size = 2>內容</td></font></tr>"; titleContent = titleContent + "<tr><td><font size = 2>日期</td></font></tr>"; titleContent = titleContent + "</table>"; titlePopupBody.innerHTML = titleContent; ShowMsgBox(); } function MsgBox() { len += 4; if (len > 110) { window.clearInterval(tID); } else {//170固定了訊息提示框的寬度 titlePopup.show(document.body.clientWidth - 170, document.body.clientHeight - len, 170, len, top.document.body); } } var tID function ShowMsgBox() { tID = window.setInterval("MsgBox()",15); } </script> <body MS_POSITIONING="GridLayout"> <INPUT id="Button1" style="Z-INDEX: 101; LEFT: 296px; POSITION: absolute; TOP: 344px" type="button" value="Button" name="Button1"> </body></html>

    [Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運行]



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.