/* 显示窗口中的div并弹出窗口方法 */ PopBubble.prototype.show = function(){ var oPopup = window.createPopup(); this.Pop = oPopup; var w = this.width; var h = this.height;
this.offset = 0; var obj = this; oPopup.document.body.onmouseover = function(){obj.pause=true;} oPopup.document.body.onmouseout = function(){obj.pause=false;} var fun = function(){ var x = obj.left; var y = 0; var width = obj.width; var height = obj.height;
<script type="text/javascript"> function unselectall(){ if(document.form1.ckAll.checked){ document.form1.ckAll.checked = document.form1.ckAll.checked&0; } } function CheckAll(form){ for (var i=0;i<form.elements.length;i++){ var e = form.elements[i]; if (e.Name != 'ckAll'&&e.disabled==false) e.checked = form1.ckAll.checked; } }
function sAlert(){ var msgw,msgh,bordercolor; msgw=600;//提示窗口的宽度 msgh=100;//提示窗口的高度 titleheight=80;//提示窗口标题高度 bordercolor="#336699";//提示窗口的边框颜色 titlecolor="#99CCFF";//提示窗口的标题颜色 var sWidth,sHeight; sWidth=document.body.offsetWidth; sHeight=document.body.offsetHeight; if (sHeight<screen.height) { sHeight=screen.height; }
http://topic.csdn.net/u/20101216/10/b98258a7-2716-4c75-9f23-6ee566a203e1.html
的讨论
<html>
<head><title>页面右下角弹出提示信息,类QQ右下角新闻,dongdongleng整理收集。</title>
<style type="text/css">
* {margin:0px;padding:0px;}
html,body {height:100%;}
body {font-size:14px; line-height:24px;}
#tip {position: absolute;right: 0px;bottom: 0px;height: 0px;width: 280px;border: 1px solid #CCCCCC;background-color: #eeeeee;padding: 1px;overflow:hidden;display:none;font-size:12px;z-index:10;}
#tip p {padding:6px;}
#tip h1,#detail h1 {font-size:14px;height:25px;line-height:25px;background-color:#33FF00;color:#FF0000;padding:0px 3px 0px 3px;}
#tip h1 a,#detail h1 a {float:right;text-decoration:none;color:#FFFFFF;}
#shadow {position:absolute;width:100%;height:100%;background:#CCCCCC;-moz-opacity:0.5;filter:Alpha(Opacity=50);opacity: 0.8;z-index:11;display:none;overflow:hidden;}
#detail {width:500px;height:200px;border:3px double #ccc;background-color:#FFFFFF;position:absolute;z-index:30;display:none;left:30%;top:30%}
</style>
<script type="text/javascript">
var handle;
function start()
{
var obj = document.getElementById("tip");
if (parseInt(obj.style.height)==0)
{ obj.style.display="block";
handle = setInterval("changeH('up')",2);
}else
{
handle = setInterval("changeH('down')",2)
}
}
function changeH(str)
{
var obj = document.getElementById("tip");
if(str=="up")
{
if (parseInt(obj.style.height)>200)
clearInterval(handle);
else
obj.style.height=(parseInt(obj.style.height)+8).toString()+"px";
}
if(str=="down")
{
if (parseInt(obj.style.height)<8)
{ clearInterval(handle);
obj.style.display="none";
}
else
obj.style.height=(parseInt(obj.style.height)-8).toString()+"px";
}
}
function showwin()
{
document.getElementsByTagName("html")[0].style.overflow = "hidden";
start();
document.getElementById("shadow").style.display="block";
document.getElementById("detail").style.display="block";
}
function recover()
{
document.getElementsByTagName("html")[0].style.overflow = "auto";
document.getElementById("shadow").style.display="none";
document.getElementById("detail").style.display="none";
}
</script>
</head><body onload="document.getElementById('tip').style.height='0px'"><div id="shadow"> </div><div id="detail"><h1><a href="javascript:void(0)" onclick="recover()">×</a>baishonglin提示您</h1>效果不错吧~_~,<a href="http://hi.baidu.com/baishonglin">baishonglin</a></div><div id="tip"><h1><a href="javascript:void(0)" onclick="start()">×</a>检测到100个系统漏洞,500个木马病毒。</h1><p><a href="javascript:void(0)" onclick="showwin()">详情请点击</a></p></div>
<div align="center"><a href="javascript:void(0)" onclick="start()">点击这里测试</a>
</p></div>
</body>
</html>
PopupWind(CString str)
{
CPopupDlg* dlg = new CPopupDlg;
//dlg.m_strTip = str; dlg->m_strTip = str;
dlg->Create(IDD_DIALOG_POPUP, NULL);
dlg->ShowWindow(SW_HIDE); CRect rc;
CRect rc_pop;
SystemParametersInfo(SPI_GETWORKAREA,0,(PVOID)&rc,0);
dlg->GetWindowRect(&rc_pop); rc.left = rc.right - rc_pop.Width();
rc.top = rc.bottom - rc_pop.Height();
dlg->MoveWindow(&rc);
::AnimateWindow(dlg->GetSafeHwnd(), 2000, AW_SLIDE|AW_VER_NEGATIVE);
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Clinic
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
double dou = 0.05;
int heigh = 0;
Form_show show = new Form_show(); //timer1空间事件
private void timer1_Tick(object sender, EventArgs e)
{
this.Opacity += dou;
if (this.Opacity == 1)
{
timer1.Stop();
dou = -0.05;
timer2.Start();
}
else if (this.Opacity == 0)
{
timer1.Stop();
this.DialogResult = DialogResult.OK;
// show.Get_Show(form);
News.News a = new Clinic.News.News();
a.Show();
}
}
//timer2空间事件
private void timer2_Tick(object sender, EventArgs e)
{
if (heigh <= 160)
{
this.panel1.Size = new System.Drawing.Size(311, heigh);
heigh += 3;
}
else
{
timer2.Stop();
}
} //关闭
private void pictureBox2_Click(object sender, EventArgs e)
{
DialogResult dia = MessageBox.Show("是否退出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dia == DialogResult.Yes)
{
show.Get_Close(this);
}
} //登录
private void btn_Login_Click(object sender, EventArgs e)
{
if (txt_LoginName.Text.Equals("admin") && txt_LoginPwd.Text.Equals("admin"))
timer1.Start();
else
………………
} //取消
private void btn_Cancel_Click(object sender, EventArgs e)
{
txt_LoginName.Text = "";
txt_LoginPwd.Text = "";
} //窗体加载事件
private void Login_Load(object sender, EventArgs e)
{
this.AcceptButton = btn_Login;
this.CancelButton = btn_Cancel;
this.Opacity = 0;
timer1.Start();
}
}
}using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Clinic.News
{
public partial class News : Form
{
public News()
{
InitializeComponent();
} //谈进谈出 效果函数调用
#region
int a = 3;
double b = 0.05;
int _y = 600;
int c = 0;
int d = 4; private void News_Load(object sender, EventArgs e)
{
this.Opacity = 0;
timer1.Start();
} private void timer1_Tick(object sender, EventArgs e)
{
_y -= a;
this.Location = new Point(850, _y);
this.Opacity += b;
if (_y == 543)
{
timer2.Start();
timer1.Stop();
}
} private void timer2_Tick(object sender, EventArgs e)
{
c += d;
if (c == 100)
{
d = 0;
this.Opacity -= 0.02;
if (this.Opacity == 0)
{
timer2.Stop();
timer2.Dispose();
this.Close();
}
}
} #endregion
//关闭窗口
private void labelX2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
height = document.body.clientHeight + 138;
windowX = screen.width - width;
windowY = screen.height - height;
window.moveTo(windowX,windowY);//移动到相对位置
构造函数,来初始化相应的属性
*/
function PopBubble(caption,content,see){
this.content = content;
this.caption= caption;
this.see= see;
this.width= 150;
this.height = 120;
this.timeout= 150;
this.speed = 15;
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;
}
/*
退宿弹出窗口的方法
*/
PopBubble.prototype.hide = function(){ var offset = this.height>this.bottom-this.top?this.height:this.bottom-this.top;
var obj = this;
if(this.timer>0){
window.clearInterval(obj.timer);
}
var fun = function(){
if(obj.pause==false||obj.close){
var x = obj.left;
var y = 0;
var width = obj.width;
var height = 0;
if(obj.offset>0){
height = obj.offset;
}
y = obj.bottom - height;
if(y>=obj.bottom){
window.clearInterval(obj.timer);
obj.Pop.hide();
} else {
obj.offset = obj.offset - obj.step;
}
obj.Pop.show(x,y,width,height);
}
}
this.timer = window.setInterval(fun,this.speed)
}
/*
实现查看超链接
*/
PopBubble.prototype.oncommand = function(){ window.parent.mainFrame.location.href="notReaderMessage.aspx";
this.close = true;
this.hide();
}
/*
显示窗口中的div并弹出窗口方法
*/
PopBubble.prototype.show = function(){
var oPopup = window.createPopup();
this.Pop = oPopup;
var w = this.width;
var h = this.height;
var str = "<DIV style='BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX: 99999; LEFT: 0px; BORDER-LEFT: #a6b4cf 1px solid; WIDTH: " + w + "px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: " + h + "px; BACKGROUND-COLOR: #DAED9B'>"
str += "<TABLE style='BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid' cellSpacing=0 cellPadding=0 width='100%' bgColor=#EEF7CC border=0>"
str += "<TR>"
str += "<TD style='FONT-SIZE: 12px;COLOR: #0f2c8c' width=30 height=24></TD>"
str += "<TD style='PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px' vAlign=center width='100%'>" + this.caption + "</TD>"
str += "</TR>"
str += "<TR>"
str += "<TD style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px' colSpan=2 height=" + (h-28) + ">"
str += "<DIV style='BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 8px; BORDER-TOP: #7AA14E 1px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; PADDING-BOTTOM: 8px; BORDER-LEFT: #7AA14E 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 8px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%'>" + this.content + "<BR><BR>"
str += "<DIV style='WORD-BREAK: break-all' align=left><A href='javascript:void(0)' hidefocus=true id='btCommand'><FONT color=#ff0000>" + this.see+"<embed id='soundControl' src='Windows.wav' mastersound hidden='true' loop='false' autostart='true'></embed>" + "</FONT></A></DIV>"
str += "</DIV>"
str += "</TD>"
str += "</TR>"
str += "</TABLE>"
str += "</DIV>"
oPopup.document.body.innerHTML = str;
this.offset = 0;
var obj = this;
oPopup.document.body.onmouseover = function(){obj.pause=true;}
oPopup.document.body.onmouseout = function(){obj.pause=false;} var fun = function(){
var x = obj.left;
var y = 0;
var width = obj.width;
var height = obj.height;
if(obj.offset>obj.height){
height = obj.height;
} else {
height = obj.offset;
}
y = obj.bottom - obj.offset;
if(y<=obj.top){
obj.timeout--;
if(obj.timeout==0){
window.clearInterval(obj.timer);
if(obj.autoHide){
obj.hide();
}
}
}
else {
obj.offset = obj.offset + obj.step;
}
obj.Pop.show(x,y,width,height);
}
this.timer = window.setInterval(fun,this.speed)
var btCommand = oPopup.document.getElementById("btCommand");
btCommand.onclick = function(){
obj.oncommand();
}
}
PopBubble.prototype.rect = function(left,right,top,bottom){
try {
this.left= this.right-this.width;
this.right=this.left +this.width;
this.bottom = screen.height;
this.top = this.bottom - this.height;
} catch(e){}
} 在后台VS2008下用ASP.NET下用ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "", "var msg = new PopBubble('短消息提示:','您有" + isRead + "封未读消息','查看'); msg.show();", true);方式调用,完全成功,测试图如下原文出处:[url=http://user.qzone.qq.com/371395204/blog/1317956209[/url]
function unselectall(){
if(document.form1.ckAll.checked){
document.form1.ckAll.checked = document.form1.ckAll.checked&0;
}
}
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.Name != 'ckAll'&&e.disabled==false)
e.checked = form1.ckAll.checked;
}
}
function sAlert(){
var msgw,msgh,bordercolor;
msgw=600;//提示窗口的宽度
msgh=100;//提示窗口的高度
titleheight=80;//提示窗口标题高度
bordercolor="#336699";//提示窗口的边框颜色
titlecolor="#99CCFF";//提示窗口的标题颜色
var sWidth,sHeight;
sWidth=document.body.offsetWidth;
sHeight=document.body.offsetHeight;
if (sHeight<screen.height)
{
sHeight=screen.height;
}
var bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="-8";
bgObj.style.background="#777";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
//bgObj.style.width = "100%";
bgObj.style.height=sHeight + "px";
//bgObj.style.height = "100%";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj); var msgObj=document.getElementById("divG2");
// msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "50%";
msgObj.style.display = "block";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px";
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw + "px";
msgObj.style.height =msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight = (msgh-titleheight) + "px";
msgObj.style.zIndex = "10001";
}
</script>
<div id="divG2" style="display:none;">//
</div>
public void Bind2()
{
if (Request.QueryString["Oid"] != null)
{
this.MessageStr.Text = "<script>sAlert();</script>";
}
}
美女,我想认识你,你手机号能给我嘛? 你加我QQ吧。。输入QQ号,对方的验证问题是:我手机号是多少?!
参考:http://msdn.microsoft.com/en-us/library/ms536392(v=VS.85).aspx
此方法猥琐,惹人讨厌,不建议使用。