最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS實(shí)現(xiàn)定時(shí)頁(yè)面彈出類似QQ新聞的提示框

 更新時(shí)間:2013年11月07日 16:33:33   作者:  
類似QQ新聞的提示框要求頁(yè)面每隔半小時(shí)彈出一次提示消息,下面有個(gè)不錯(cuò)的實(shí)現(xiàn)方法,感興趣的朋友可以參考下
還是在做聯(lián)通IOM項(xiàng)目時(shí)遇到的一個(gè)需求,要求頁(yè)面每隔半小時(shí)彈出一次提示消息(消息以類似QQ新聞的形式彈出)。當(dāng)時(shí)上網(wǎng)找的這么一個(gè)資料,已經(jīng)不記得原文出處了
復(fù)制代碼 代碼如下:

<html>
<head>
<title>JavaScript提示框</title>

<script type="text/javascript">
<!--

/**
* 類名:CLASS_MSN_MESSAGE
* 功能:提供類似MSN消息框
* 示例:
* var MSG = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有1封消息","今天請(qǐng)我吃飯哈");
* MSG.show();
* 消息構(gòu)造
*/
function CLASS_MSN_MESSAGE(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:200;
this.height = height?height:120;
this.timeout = 150;
this.speed = 20;
this.step = 1;
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;
}

/**
* 隱藏消息方法
*/
CLASS_MSN_MESSAGE.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);
} else {
me.offset = me.offset - me.step;
}
me.Pop.show(x,y,width,height);
}
}
this.timer = window.setInterval(fun,this.speed)
}
}

/**
* 消息卸載事件,可以重寫
*/
CLASS_MSN_MESSAGE.prototype.onunload = function() {
return true;
}
/**
* 消息命令事件,要實(shí)現(xiàn)自己的連接,請(qǐng)重寫它
*/
CLASS_MSN_MESSAGE.prototype.oncommand = function(){
this.close = true;
this.hide();
window.open("http://www.lost63.com");
}
/**
* 消息顯示方法
*/
CLASS_MSN_MESSAGE.prototype.show = function(){
var oPopup = window.createPopup(); //IE5.5+
this.Pop = oPopup;

var w = this.width;
var h = this.height;

// "×"關(guān)閉按鈕
/*
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 += "<td style='padding-right: 2px; padding-top: 2px' valign=center align=right width=19>"
str += "<span title=關(guān)閉 style='font-weight: bold; font-size: 12px; cursor: hand; color: red; margin-right: 4px' id='btsysclose' >×</span></td>"
str += "</tr>"
*/
// 按鈕style
// style='width:60px; height:20px; border-right: #002D96 1px solid; padding-right: 2px; border-top: #002D96 1px solid; padding-left: 2px; FONT-SIZE: 12px; filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#FFFFFF, EndColorStr=#9DBCEA); border-left: #002D96 1px solid; CURSOR: hand; color: black; padding-top: 2px; border-bottom: #002D96 1px solid;'

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: #c9d3f3'>"
str += "<table style='border-top: #ffffff 1px solid; border-left: #ffffff 1px solid' cellspacing=0 cellpadding=0 width='100%' bgcolor=#cfdef4 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>"
/*height:設(shè)置里面內(nèi)容區(qū)域的高度 */
str += "<td style='padding-right: 1px;padding-bottom: 1px' colspan=3 height=" + (h-50) + ">"
str += "<div style='border-right: #b9c9ef 1px solid; padding-right: 8px; border-top: #728eb8 1px solid; padding-left: 8px; font-size: 12px; padding-bottom: 8px; border-left: #728eb8 1px solid; width: 100%; color: #1f336b; padding-top: 8px; border-bottom: #b9c9ef 1px solid; height: 100%'>" + this.title + "<br><br>"
str += "<div style='word-break: break-all' align=left><a href='javascript:void(0)' hidefocus=false id='btcommand'><font color=#ff0000>" + this.message + "</font></a> - <a href='tencent://message/?uin=380522459&site=http://hi.baidu.com/lupeng0527&menu=yes' hidefocus=false id='ommand'><font color=#ff0000>有事您q我!</font></a></div>"
str += "</div>"
str += "</td>"
str += "</tr>"
str += "<tr align=center>"
str += "<td colspan=3>"
str += "<div style='padding: 2 0 2 0;'>"
str += "<span id='buttonClose'><input type='button' title=關(guān)閉 value=確認(rèn) style='width:60px; height:20px; border-right: #002D96 1px solid; padding-right: 2px; border-top: #002D96 1px solid; padding-left: 2px; FONT-SIZE: 12px; filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#FFFFFF, EndColorStr=#9DBCEA); border-left: #002D96 1px solid; CURSOR: hand; color: black; padding-top: 2px; border-bottom: #002D96 1px solid;'></span>"
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=true;}

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)

//"確認(rèn)"關(guān)閉事件

var buttonClose = oPopup.document.getElementById("buttonClose");
buttonClose.onclick = function(){
me.close = true;
me.hide();
}
/*
* "×"關(guān)閉事件
* 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();
}
var ommand = oPopup.document.getElementById("ommand");
ommand.onclick = function(){
this.close = true;
me.hide();
window.open(ommand.href);
}
}
/*
* 設(shè)置速度方法
*/
CLASS_MSN_MESSAGE.prototype.speed = function(s){
var t = 20;
try {
t = praseInt(s);
} catch(e){}
this.speed = t;
}
/**
* 設(shè)置步長(zhǎng)方法
*/
CLASS_MSN_MESSAGE.prototype.step = function(s){
var t = 1;
try {
t = praseInt(s);
} catch(e){}
this.step = t;
}

CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){
try {
this.left = left !=null?left:this.right-this.width;
this.right = right !=null?right:this.left +this.width;
this.bottom = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height;
this.top = top !=null?top:this.bottom - this.height;
} catch(e){}
}
var MSG1 = new CLASS_MSN_MESSAGE("aa",240,150,"管理員:","思路決定出路","迷失路上");
MSG1.rect(null,null,null,screen.height-50);
MSG1.speed = 10;
MSG1.step = 5;
//alert(MSG1.top);
//MSG1.show();
//同時(shí)兩個(gè)有閃爍,只能用層代替了,不過層不跨框架
/*
var MSG2 = new CLASS_MSN_MESSAGE("aa",200,120,"短消息提示:","您有2封消息","好的啊");
MSG2.rect(100,null,null,screen.height);
MSG2.show();
*/

/**
* 顯示提示框
*/
function showMSG(){
MSG1.show();
}

</script>
</head>

<body>
<center>
<bgsound src="" id="bs" loop="no">
<input type="button" value="按鈕" onclick="showMSG(); ">
<br>
<hr>
</center>
</body>
</html>

相關(guān)文章

  • 關(guān)于JS變量和作用域詳解

    關(guān)于JS變量和作用域詳解

    下面小編就為大家?guī)?lái)一篇關(guān)于JS變量和作用域詳解。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2016-07-07
  • 詳解JavaScript中的閉包是如何產(chǎn)生的

    詳解JavaScript中的閉包是如何產(chǎn)生的

    這篇文章主要為大家詳細(xì)介紹了從內(nèi)存管理的角度來(lái)看,JavaScript中的閉包是如何產(chǎn)生的。文中的示例代碼簡(jiǎn)潔易懂,感興趣的小伙伴可以了解一下
    2022-12-12
  • 旺旺在線客服代碼 旺旺客服代碼生成器

    旺旺在線客服代碼 旺旺客服代碼生成器

    很多朋友想在網(wǎng)站上插入自己的阿里旺旺在線聯(lián)系圖片,就像是和QQ一樣,小編為大家詳細(xì)講解了旺旺在線客服代碼以及旺旺客服代碼生成器,希望能夠幫助到大家。
    2018-01-01
  • Js 獲取當(dāng)前函數(shù)參數(shù)對(duì)象的實(shí)現(xiàn)代碼

    Js 獲取當(dāng)前函數(shù)參數(shù)對(duì)象的實(shí)現(xiàn)代碼

    這篇文章主要介紹了Js 獲取當(dāng)前函數(shù)參數(shù)對(duì)象的實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2016-06-06
  • Nest.js快速啟動(dòng)API項(xiàng)目過程詳解

    Nest.js快速啟動(dòng)API項(xiàng)目過程詳解

    這篇文章主要為大家介紹了Nest.js快速啟動(dòng)API項(xiàng)目過程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10
  • JS實(shí)現(xiàn)圖片瀑布流效果

    JS實(shí)現(xiàn)圖片瀑布流效果

    這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)圖片瀑布流,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Electron autoUpdater實(shí)現(xiàn)Windows安裝包自動(dòng)更新的方法

    Electron autoUpdater實(shí)現(xiàn)Windows安裝包自動(dòng)更新的方法

    這篇文章主要介紹了Electron autoUpdater實(shí)現(xiàn)Windows安裝包自動(dòng)更新的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2018-12-12
  • VC調(diào)用javascript的幾種方法(推薦)

    VC調(diào)用javascript的幾種方法(推薦)

    下面小編就為大家?guī)?lái)一篇VC調(diào)用javascript的幾種方法(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2016-08-08
  • JavaScript對(duì)象的創(chuàng)建模式與繼承模式示例講解

    JavaScript對(duì)象的創(chuàng)建模式與繼承模式示例講解

    繼承機(jī)制是面向?qū)ο蟪绦蛟O(shè)計(jì)使代碼可以復(fù)用的最重要的手段,它允許程序員在保持原有的特性基礎(chǔ)上進(jìn)行擴(kuò)展,增加功能,這樣產(chǎn)生新的類,稱作是派生類。繼承呈現(xiàn)了面向?qū)ο蟪绦蛟O(shè)計(jì)的層析結(jié)構(gòu),體現(xiàn)了由簡(jiǎn)單到復(fù)雜的認(rèn)知過程。繼承是類設(shè)計(jì)層次的復(fù)用
    2022-12-12
  • 如何利用Web Speech API之speechSynthesis實(shí)現(xiàn)文字轉(zhuǎn)語(yǔ)音功能

    如何利用Web Speech API之speechSynthesis實(shí)現(xiàn)文字轉(zhuǎn)語(yǔ)音功能

    Web Speech API使你能夠?qū)⒄Z(yǔ)音數(shù)據(jù)合并到Web應(yīng)用程序中,SpeechSynthesisUtterance是HTML5中新增的API,用于將指定文字合成為對(duì)應(yīng)的語(yǔ)音,這篇文章主要介紹了利用Web Speech API之speechSynthesis實(shí)現(xiàn)文字轉(zhuǎn)語(yǔ)音功能,需要的朋友可以參考下
    2024-06-06

最新評(píng)論

连城县| 志丹县| 定襄县| 信丰县| 庆安县| 车致| 肃北| 庆城县| 宁陕县| 彭阳县| 怀集县| 甘肃省| 当阳市| 金塔县| 台湾省| 泰州市| 兴城市| 青海省| 芒康县| 平阴县| 张北县| 土默特左旗| 普格县| 崇左市| 和硕县| 汉阴县| 哈尔滨市| 永德县| 五指山市| 商都县| 澄迈县| 习水县| 北宁市| 富宁县| 莱西市| 曲阜市| 定结县| 中卫市| 朝阳市| 开封县| 南丹县|