Use JavaScript as a message box (similar to the QQ user online message prompt)

Source: Internet
Author: User
Tags date generator setinterval window visual studio
Javascript

In the development of the project, the need to have users when the message to remind users, just their QQ friends online, QQ automatically pop-up a message prompt, feel good. So use JavaScript to make a similar function with Popup.

<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" >

<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% ' Cellspacing=0 cellpadding=0> ";
Titlecontent = titlecontent + "<tr><td align=center><font size = 2> message Reminder </font></td></ Tr> ";
Titlecontent = titlecontent + "<tr><td><font size = 2> content </td></font></tr>";
Titlecontent = titlecontent + "<tr><td><font size = 2> content </td></font></tr>";
Titlecontent = titlecontent + "<tr><td><font size = 2> date </td></font></tr>";
Titlecontent = titlecontent + "</table>";
titlepopupbody.innerhtml = titlecontent;

Showmsgbox ();
}

function MsgBox ()
{
Len + 4;
if (Len > 110)
{
Window.clearinterval (TID);
}
Else
{//170 fixed the width of the message prompt box
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>

<ptml> <pead> <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" > </pead> <script language =javasc ript> 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% ' Cellspacing=0 cellpadding=0> "; Titlecontent = titlecontent + "<tr><td align=center><font size = 2> message Reminder </font></td></ Tr> "; TitleconteNT = titlecontent + "<tr><td><font size = 2> content </td></font></tr>"; Titlecontent = titlecontent + "<tr><td><font size = 2> content </td></font></tr>"; Titlecontent = titlecontent + "<tr><td><font size = 2> date </td></font></tr>"; Titlecontent = titlecontent + "</table>"; titlepopupbody.innerhtml = titlecontent; Showmsgbox (); function MsgBox () {len + + 4; if (Len >) {window.clearinterval (TID); else {//170 fixed the width of the message prompt box Titlepopup.show (document.body.clientwidth-170, document.body.clientheight-l En, 170, Len, top.document.body); The Var TID function Showmsgbox () {TID = Window.setinterval ("MsgBox ()", 15); } </script> <body ms_positioning= "GridLayout" > <input id= "Button1" style=; left:296px; Position:absolute; Top:344px "Type=" butTon "value=" button "Name=" Button1 "> </body></ptml>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.