日期:2014-05-17  浏览次数:20780 次

关于弹出式消息框的问题,请教
现在很多bbs都有站内短信功能,我想当有新短信的时候,再我的电脑右下角弹出类似msn的消息提示框,如何才能做到,请给点提示

------解决方案--------------------
使用xmlhttp技术
<script language= "javascript ">
<!--
function GetResult()
{
var xmlObj = new ActiveXObject( "Microsoft.XMLHTTP ");
xmlObj.open( "POST ", "getMsg.asp ",false);
xmlObj.send();
var strResult = unescape(xmlObj.responseText);
if(strResult != " "){
myFun();
}
}
function myShow(){
timer=window.setInterval( "GetResult() ",30000);
}
-->
</script>
<script> myShow() </script>
其中:
1、getMsg.asp文件是提取数据库里新的信息,当然,新短信要设置一个标示,例如 "N "表示未读短信,代码自己写。
2、window.setInterval( "GetResult() ",30000); 表示每隔30秒检测一次是否有新短信。
3、 <script> myShow() </script> 表示在该页面调用
4、myFun();表示要弹出提示窗口的函数,弹出窗口的javascript代码网上搜索。

------解决方案--------------------
方法一:

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>

</BODY>
<script language= "JavaScript ">
<!--
var oPopup = window.createPopup(); //IE5.5+

var str = " <table id=mypopup border=1 cellpadding=2 cellspacing=0 width=300 height=130 style= 'background: menu '> ";
str += " <tr> <td> dfghfdhfhttttttt </td> </tr> ";

str += " </table> ";
oPopup.document.body.innerHTML = str;

var w = oPopup.document.all.mypopup.width;
var h = oPopup.document.all.mypopup.height;
var x = 500;
var y = 400;

var docWidth = document.body.clientWidth;
var docHeight = document.body.clientHeight;
timer = setInterval( "movePop() ",1)
var tmp = h
function movePop(){
if(tmp == 0)
clearInterval(timer);
oPopup.show(docWidth-w + 7, docHeight + tmp, w, h);
tmp = tmp - 5;


}
//-->
</script>

</HTML>

方法二:

<SCRIPT Language=Javascript>
<!--
var oPopup = window.createPopup();
var popTop=50;
function popmsg(msgstr){
var winstr= " <table width=\ "241\ " height=\ "180\ " border=\ "0\ " cellpadding=\ "0\ " cellspacing=\ "0\ "> ";
winstr+= " <tr> <td align=\ "center\ "> <table width=\ "90%\ " height=\ "180\ " border=\ "0\ " cellpadding=\ "0\ " cellspacing=\ "0\ "> ";
winstr+= " <tr> <td align=\ "center\ "> <table width=\ "90%\ " height=\ "180\ " border=\ "0\ " cellpadding=\ "0\ " cellspacing=\ "0\ "> ";
winstr+= " <tr> <td valign=\ "top\ " style=\ "font-size:12px;\ "> "+msgstr+ " </td> </tr> </table> </td> </tr> </table> ";
oPopup.document.body.innerHTML = winstr;
popshow();
}
function popshow(){
window.status=popTop;
if(popTop> 1720){
clearTimeout(mytime);
oPopup.hide();