JavaScript MSN 弹出消息框
** 功能:提供类似MSN消息框
** 示例:
** 作者:ttyp
** 邮件:ttyp@21cn.com
** 日期:2005-3-18
**
**/
JS 代码:
// JScript 文件
/*
caption 标题栏
title 消息标题
message 消息主题
target 链接框架
action 链接地址
*/
function MessShow(id,width,height,caption,title,message,target,action)
{
this.id = id;
this.title = title;
this.caption = caption;
this.message = message;
this.target = target;
this.action = action;
this.width = width?width:250;
this.height = height?height:150;
this.timeout = 250; //消息停留时间
this.speed = 10; //消息速度,越小越快
this.step = 2; //移动步长
this.right = screen.width -1;
this.bottom = screen.height;
this.left = this.right - this.width;
this.top = this.bottom - this.height;
this.timer = 0;
this.pause = false;
this.close = false;
this.autoHide = true;
}
// 隐藏消息方法
MessShow.prototype.hide = function()
{
if(this.onunload())
{
var offset = this.height>this.bottom-this.top?this.height:this.bottom-this.top;
var me = this;
if(this.timer>0)
{
window.clearInterval(me.timer);
}
var fun = function()
{
if(me.pause==false||me.close)
{
var x = me.left;
var y = 0;
var width = me.width;
var height = 0;
if(me.offset>0){
height = me.offset;
}
y = me.bottom - height;
if(y>=me.bottom){
window.clearInterval(me.timer);
me.Pop.hide();
} else {
me.offset = me.offset - me.step;
}
me.Pop.show(x,y,width,height);
}
}
this.timer = window.setInterval(fun,this.speed)
}
}
//消息卸载事件,可以重写
MessShow.prototype.onunload = function()
{
return true;
}
// 消息命令事件,要实现自己的连接,请重写它
MessShow.prototype.oncommand = function()
{
window.open(this.action,this.target);
this.hide();
}
// 消息显示方法
MessShow.prototype.show = function()
{
var oPopup = window.createPopup(); //IE5.5+
this.Pop = oPopup;
var w = this.width;
var h = this.height;
var str = "<DIV style='BORDER-RIGHT:#005FEE 1px solid; BORDER-TOP:#005FEE 1px solid; Z-INDEX: 99999; LEFT: 0px; BORDER-LEFT:#005FEE 1px solid; WIDTH: " + w + "px; BORDER-BOTTOM:#005FEE 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: " + h + "px; BACKGROUND-COLOR:#FFFFFF'>"
str += "<TABLE style='BORDER-TOP: #FFFFFF 1px solid; BORDER-LEFT: #FFFFFF 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#FFFFFF border=0>"
str += "<TR>"
str += "<TD style='FONT-SIZE: 12px;COLOR: #0052CC' width=30 height=24>∵</TD>"
str += "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR:#0052CC; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.caption + "</TD>"
str += "<TD style='PADDING-RIGHT: 2px; PADDING-TOP: 2px' vAlign=center align=right width=19>"
str += "<SPAN title=关闭 style='FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px' id='btSysClose' >×</SPAN></TD>"
str += "</TR>"
str += "<TR>"
str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=3 height=" + (h-28) + ">"
str += "<DIV style='BORDER-RIGHT: FFFFFF 1px solid; PADDING-RIGHT: 8px; BORDER-TOP:#66A3FF 1px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; PADDING-BOTTOM: 8px; BORDER-LEFT:#FFFFFF 1px solid; WIDTH: 100%; COLOR:#FFFFFF; PADDING-TOP: 8px; BORDER-BOTTOM:#FFFFFF 1px solid; HEIGHT: 100%'><FONT color=#EE0000>" + this.title + "</FONT><BR><BR>"
str += "<DIV style='WORD-BREAK: break-all' align=left><A href='javascript:void(0)' hidefocus=true id='btCommand'><FONT color=#EE0000>" + this.message + "</FONT></A></DIV>"
str += "</DIV>"
str += "</TD>"
str += "</TR>"
str += "</TABLE>"
str += "</DIV>"
oPopup.document.body.innerHTML = str;
this.offset = 0;
var me = this;
oPopup.document.body.onmouseover = function(){me.pause=true;}
oPopup.document.body.onmouseout = function(){me.pause=false;}
var fun = function()
{
var x = me.left;
var y = 0;
var width = me.width;
var height = me.height;
if(me.offset>me.height)
{
height = me.height;
} else
{
height = me.offset;
}
y = me.bottom - me.offset;
if(y<=me.top)
{
me.timeout--;
if(me.timeout==0)
{
window.clearInterval(me.timer);
if(me.autoHide)
{
me.hide();
}
}
}
else
{
me.offset = me.offset + me.step;
}
me.Pop.show(x,y,width,height);
}
this.timer = window.setInterval(fun,this.speed)
var btClose = oPopup.document.getElementById("btSysClose");
btClose.onclick = function()
{
me.close = true;
me.hide();
}
var btCommand = oPopup.document.getElementById("btCommand");
btCommand.onclick = function()
{
me.oncommand();
}
}
// 设置速度方法
MessShow.prototype.speed = function(s)
{
var t = 10;
try
{
t = praseInt(s);
}
catch(e){}
this.speed = t;
}
// 设置步长方法
MessShow.prototype.step = function(s)
{
var t = 2;
try
{
t = praseInt(s);
}
catch(e){}
this.step = t;
}
MessShow.prototype.rect = function(left,right,top,bottom)
{
try
{
this.left = left?left:0;
this.right = right?right:screen.availWidth -1;
this.top = top?top:0;
this.bottom = bottom?bottom:screen.availHeight;
}
catch(e)
{}
}
后台代码:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>MSN 弹出消息框</title>
<script language=javascript type="text/javascript" src="MsnPup.js"></script>
<script language=javascript type="text/javascript">
function load()
{
var msg = new MessShow("love",250,150,"信息","天山寒雪,你好!","QQ:757015000 请求加为好友!","_bank",'http://www.baidu.com');
msg.show();
}
</script>
</head>
<body οnlοad="load()">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
转载于:https://www.cnblogs.com/qinhaijun/archive/2011/08/26/2154446.html
JavaScript MSN 弹出消息框相关推荐
- .NET MessageBox 网页弹出消息框
方法一: #region Alert 弹出消息框 /// <summary> /// 弹出消息框 /// </summary> ...
- jquery easyui 弹出消息框
PS:easyui 弹出消息框 系项目中实践中遇到的问题,特此转载收藏 <html> <head> <!-- 导入easyui插件的js和css样式; --> &l ...
- ASP.NET中WEB上弹出消息框的N种方法(为了以后方便,转了很多网友的文章!希望不会介意)...
ASP.NET中WEB上弹出消息框的N种方法 第一个确定之后跳转到另一页面,第二个确定之后返回前一页 Response.Write("<script langage='javascri ...
- c语言mfc弹出窗口函数,CMFCDesktopAlertWnd实现桌面弹出消息框
1.创建一个CMFCDesktopAlertWnd指针 CMFCDesktopAlertWnd* pPopup = new CMFCDesktopAlertWnd; 2.设置参数 pPopup-> ...
- 金蝶EAS 弹出消息框
MsgBox类提供了几种类型的消息框来弹出提示消息, 一般有showInfo(),showWarning(),showError(),showConfirm2() 等等.每种方法都有传入不同参数的重 ...
- QT QMessageBox 弹出消息框,对话确认框(确定/取消)
1.普通消息框,无互动 QMessageBox::information(this, QString::fromLocal8Bit("警告"),QString::fromLocal ...
- mshta命令用法示例(在dos命令弹出消息框)
JS: 复制代码代码如下: mshta vbscript:window.execScript("alert('hello world!');","javascript&q ...
- C++:控制台程序弹出消息框
#include "stdafx.h" #include<windows.h> //不显示控制台 #pragma comment( linker, "/sub ...
- 在用户控件中弹出消息框的方法
以下语句可以弹出消息框, 如有不妥,请指正! ScriptManager.RegisterStartupScript(this, GetType(), "js", "al ...
最新文章
- Android安卓游戏引擎大搜罗
- sql中exists,not exists的用法
- Shell中read的常用方式
- Android中Alertdialog对话框点击消失?
- C++中引用的一些问题
- php检查图片大小,如何利用Javascript函数检查图片大小
- java中configmanager_Spring4新的javaConfig注解
- linux上安装shell编辑器与linux运维面试题
- python怎么设置颜色深浅变化_机器学习中减弱不同图像数据色调及颜色深浅差异...
- python是什么-了解什么是Python面向对象(1)
- MNN(二):借助Opencv实现MNN推理
- 【银行】2016年中国银行信息科技岗 笔试+面试经验汇总。。。。《转》
- Excel冻结窗格纪要
- 计算机网络设计前三层实验,基于Packet Tracer的计算机网络实验设计
- 湖南农业大学有计算机应用,计算机应用基础复习资料–湖南农业大学.doc
- MySQL数据结构选择的合理性
- 皕杰报表自定义扩展~自定义数据集
- Android GoogleMap 接入
- Java移位运算符详解实例——左移位运算符、带符号的右移位运算符
- 重磅!谷歌发布《深度学习调优手册》!Hinton转发点赞!
热门文章
- spacy 报错 gold.pyx in spacy.gold.GoldParse.__init__() 解决方案
- LeetCode 767. 重构字符串(堆)
- LeetCode 123. 买卖股票的最佳时机 III(动态规划)
- LeetCode 1389. 按既定顺序创建目标数组
- POJ 2255 Tree Recovery(已知前序中序,求后序)
- python哪本书好看_python入门看哪本书好
- 包概念与__init__注意事项
- 改变世界,改善生活:我从科沃斯扫地机器人X1,看到了AI新的希望
- 简化Swagger使用的自制Starter:spring-boot-starter-swagger,欢迎使用和吐槽
- 阿里P8架构师谈:开源搜索引擎Lucene、Solr、Sphinx等优劣势比较