javascript實(shí)現(xiàn)簡(jiǎn)單的頁(yè)面右下角提示信息框
由于之前找到一個(gè)開(kāi)源的很好用,可以固定在瀏覽器的右下角;兼容性也很好;加上之后影響到應(yīng)用的一個(gè)小功能點(diǎn),決定重寫(xiě)一個(gè);這個(gè)只能固定在當(dāng)前頁(yè)面的右下加,系統(tǒng)是上下結(jié)構(gòu)滿(mǎn)足需求,沒(méi)在繼續(xù)擴(kuò)展;
兩個(gè)函數(shù):
1.lay -- 設(shè)置提示框高寬(可選)
2.show -- 設(shè)置標(biāo)題,內(nèi)容,和停留時(shí)間
notice.js
var time;
var delayTime;
$(function(){
// 增加浮動(dòng)DIV
$('body').append("<div id='notice' onselectstart='return false'><span class='notice_title'> </span><span class='cbtn'>[關(guān)閉]</span><div class='notice_content'></div></div>");
// 更改樣式
$('#notice').css({right:"0",bottom:"0",cursor:"default",position:"fixed","background-color":"#CFDEF4",color:"#1F336B","z-index":"999",border:"1px #1F336B solid",margin:"2px",padding:"10px","font-weight":"bold","line-height":"25px",display:"none"});
$('#notice .cbtn').css({color:"#FF0000",cursor:"pointer","padding-right":"5px",float:"right",position:"relative"});
$('#notice .notice_content').css({margin:"3px","font-weight":"normal",border:"1px #B9C9EF solid","line-height":"20px","margin-bottom":"10px",padding:"10px"});
/* 綁定事件*/
$('#notice').hover(
function(){
$(this).stop(true,true).slideDown();
clearTimeout(time);
},
function(){
time = setTimeout('_notice()',delayTime);
}
);
//綁定關(guān)閉事件
$('.cbtn').bind('click',function(){
$('#notice').slideUp('fast');
clearTimeout(time);
});
});
$.extend({
lay:function(_width,_height){
$('#notice').css({width:_width,height:_height});
},
show:function(_title,_msg,_time){
delayTime = _time;
$('.notice_title').html(_title);
$('.notice_content').html(_msg);
$('#notice').slideDown(2000);
time = setTimeout('_notice()',delayTime);
},
});
function _notice(){
$('#notice').slideUp(2000);
}
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>index.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
<meta http-equiv="description" content="this is my page"/>
<meta http-equiv="content-type" content="text/html; charset=GBK"/>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body onload='initPage();'>
</body>
<script type="text/javascript">
function initPage(){
var returnMsg = "<p>信息1 jquery-1.7.2.min.js</p><p>信息2 notice.js</p><p>信息3</p>";
$.show('提示信息',returnMsg,10000);
}
</script>
<script src="jquery-1.7.2.min.js" type="text/javascript" ></script>
<script src="notice.js" type="text/javascript" ></script>
</html>
以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。
相關(guān)文章
數(shù)據(jù)庫(kù)管理工具PHPMyAdmin
這篇文章主要為大家介紹了數(shù)據(jù)庫(kù)管理工具PHPMyAdmin使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-09-09
簡(jiǎn)單談?wù)凧S數(shù)組中的indexOf方法
最近在工作中遇到一個(gè)小問(wèn)題,這篇文章代碼我會(huì)簡(jiǎn)化成小例子展示給大家。給大家詳細(xì)的介紹JS數(shù)組中的indexOf方法,用心看到最后會(huì)有收獲哈,有需要的朋友們下面來(lái)一起看看吧。2016-10-10
微信小程序性能優(yōu)化之checkSession的使用
這篇文章主要介紹了微信小程序性能優(yōu)化之checkSession的使用,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-03-03
JS獲取scrollHeight問(wèn)題想到的標(biāo)準(zhǔn)問(wèn)題
如果沒(méi)有文檔聲明可以用 document.body.scrollHeight,如果有文檔聲明必須用 document.documentElement.scrollHeight關(guān)于這方面的東西2007-05-05
Bootstrap實(shí)現(xiàn)模態(tài)框效果
這篇文章主要為大家詳細(xì)介紹了Bootstrap實(shí)現(xiàn)模態(tài)框效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-09-09

