隨筆-1  評(píng)論-44  文章-3  trackbacks-0

          ???????163在免費(fèi)郵箱在界面上花費(fèi)了不少工夫,除了用了ajax來(lái)提高用戶體驗(yàn)外,另一個(gè)亮點(diǎn)就是他的彈出框,去年看見(jiàn)申楠(qq:38371354 email:amushen1@yahoo.com.cn)同志在網(wǎng)上發(fā)布了一個(gè)163彈出框的模擬程序,看了之后覺(jué)得很不錯(cuò),不過(guò)還有些不盡人意的地方。不過(guò)由于很忙,一直沒(méi)時(shí)間改進(jìn),今年有一個(gè)項(xiàng)目需要用到這樣好的界面于是找了點(diǎn)空閑時(shí)間改了一下。最近有些人在向我詢問(wèn)相關(guān)的東西,所以特地把他發(fā)到網(wǎng)上來(lái)為一些需要的人提供需要
          ??????改了程序之后,我發(fā)現(xiàn)這個(gè)程序并不能滿足我的需要(功能上),因?yàn)檫@樣模擬出來(lái)的彈出框不具備模態(tài)性,不能讓程序停在彈出框那個(gè)地方。比如這樣一段程序
          ??????<script language="javascript">
          ???????????????alert("test");
          ???????????????window.open("about:blank");
          ??????</script>
          ??????如果是用瀏覽器自帶的alert,在我們點(diǎn)確定之后才會(huì)執(zhí)行window.open;而用模擬出來(lái)的,他在執(zhí)行了alert的同時(shí)還會(huì)執(zhí)行window.open。可是這并不是我所需要的,鑒于此,我沒(méi)有用這段程序。不過(guò)在沒(méi)有涉及到模態(tài)性的方面時(shí),我們是可以用的。大家如何取舍就看自己的需求了。

          <script>
          function clk_yes(){
          ?alert("你也同意了我的觀點(diǎn)");
          }
          function clk_no(){
          ?alert("不是你眼花了就是我眼花了!");
          }

          </script>
          <body>
          <button onClick="alert('我覺(jué)得今天天氣真的很不錯(cuò)!')">test</button>
          <button onClick="confirm('今天天氣真的很好啊,難道不是么?','clk_yes','clk_no','就算是吧','亂講')">詢問(wèn)框測(cè)試</button>

          <p><br>
          ? <br>
          ? <br>
          彈出提示的音效文件是:snd.mp3</p>
          <p>如果需要可以替換成其它文件,文件名要設(shè)置成snd.mp3</p>
          <p>版本1.2修改:<br>
          ? 1、主要修改了滾屏出現(xiàn)的問(wèn)題
          </p>
          <p>版本1.1修改:<br>
          ? 1、增加了詢問(wèn)框的功能。<br>
          ? 2、增加了音效功能<br>
          ? 3、修飾界面</p>
          ?
          <p><b>黑旋風(fēng)(LCKKING)Mail:lewclear97@163.com QQ:23929003</b><br>版本1.2修改:<br>
          ?由于最近在做一個(gè)東西,需要對(duì)界面設(shè)計(jì)的很友好,所以借用了你的源代碼,但是你的作品還有些BUG以及不足,<br>
          ?例如alert之后如果按tab鍵,焦點(diǎn)會(huì)回到主頁(yè)面上去,這樣就不安全了。聲音加載的時(shí)候,頁(yè)面會(huì)閃一下,<br>
          ?也不是很好,詢問(wèn)框按鈕文字windows的沒(méi)法改,難道自己模擬的也沒(méi)法改嗎?(當(dāng)然,我把他改了)。<br>
          ?同原作一樣,沒(méi)考慮跨瀏覽器,以后有機(jī)會(huì)再改了<br>
          ?對(duì)了,你的函數(shù)上原來(lái)的那些注釋(如:日期、作者等)寫(xiě)得那么多,看程序覺(jué)得不方便,就刪除了,不要介意!<br>
          ?總之謝謝了,為了感謝網(wǎng)友的無(wú)私,我也把改了的代碼發(fā)給大家,希望對(duì)大家有所幫助,獻(xiàn)丑了!<br>?
          ? 1、由于聲音加載會(huì)使頁(yè)面跳一下,我不太喜歡,去掉了這個(gè)功能,希望不要介意。<br>
          ? 2、改成面向?qū)ο笤O(shè)計(jì),這樣更加合理一點(diǎn)(個(gè)人意見(jiàn))<br>
          ? 3、擴(kuò)展了詢問(wèn)框的按鈕文字參數(shù)設(shè)置<br>
          ? 4、覆蓋了系統(tǒng)自帶的alert和confirm方法,如果大家不喜歡,把頭上那2句話刪除就可以了<br>
          ? 5、支持鍵盤(pán)操作。</p>
          <script language="javascript">
          ?/**
          ?* 功能:顯示提示窗口
          ?* 作者:申楠 qq:38371354 email:amushen1@yahoo.com.cn http;//amushen.cnblogs.com
          ?* 日期:2005-10-26
          ?* 版本:1.1
          ?* 備注:版權(quán)沒(méi)有,隨便拷貝,如果用于商業(yè)應(yīng)用請(qǐng)通知本人,同時(shí)保留這段注釋。
          ?*
          ?*/
          ?/**
          ? * 改造:黑旋風(fēng) QQ:23929003 email:lewclear97@163.com
          ? * 日期:2006-03-17
          ? * 版本:1.2
          ? * 說(shuō)明:本人在申楠同志的《顯示提示窗口》基礎(chǔ)上所改
          ? * 由于最近在做一個(gè)東西,需要對(duì)界面設(shè)計(jì)的很友好,所以借用了你的源代碼,但是你的作品還有些BUG以及不足,
          ??例如alert之后如果按tab鍵,焦點(diǎn)會(huì)回到主頁(yè)面上去,這樣就不安全了。聲音加載的時(shí)候,頁(yè)面會(huì)閃一下,
          ??也不是很好,詢問(wèn)框按鈕文字windows的沒(méi)法改,難道自己模擬的也沒(méi)法改嗎?(當(dāng)然,我把他改了)。
          ??同原作一樣,沒(méi)考慮跨瀏覽器,以后有機(jī)會(huì)再改了
          ??對(duì)了,你的函數(shù)上原來(lái)的那些注釋(如:日期、作者等)寫(xiě)得那么多,看程序覺(jué)得不方便,就刪除了,不要介意!
          ??總之謝謝了,為了感謝網(wǎng)友的無(wú)私,我也把改了的代碼發(fā)給大家,希望對(duì)大家有所幫助,獻(xiàn)丑了!
          ??1、由于聲音加載會(huì)使頁(yè)面跳一下,我不太喜歡,去掉了這個(gè)功能,希望不要介意。
          ??2、改成面向?qū)ο笤O(shè)計(jì),這樣更加合理一點(diǎn)(個(gè)人意見(jiàn))
          ??3、擴(kuò)展了詢問(wèn)框的按鈕文字參數(shù)設(shè)置
          ??4、覆蓋了系統(tǒng)自帶的alert和confirm方法,如果大家不喜歡,把頭上那2句話刪除就可以了
          ??5、支持鍵盤(pán)操作。
          ??備注:同上
          ? */
          ?
          ?var alternateFrame=null;//生成的iframe
          ?var alternateWin=null;

          ?window.alert=showAlert;
          ?window.confirm=showConfirm;
          ?
          ?/**
          ? * 人機(jī)交互窗口,覆蓋自帶的
          ? */
          ?function alternateWindow(){
          ??this.win=null;//生成對(duì)話框的窗口對(duì)象
          ??this.pBody=null;//生成的body容器對(duì)象
          ??this.pBg=null;
          ??this.type="alert";//默認(rèn)的種類(lèi)是alert
          ??this.FocusWhere="OK";//焦點(diǎn)在哪個(gè)按鈕上
          ?}
          ?/**
          ? * 模仿的alert窗口
          ? */
          ?function showAlert(info){
          ??alternateWin=new alternateWindow();
          ??var pBody = alternateWin.init();??
          ??alternateWin.initAlertBody(pBody,info);
          ??alternateWin.type="alert";
          ?}
          ? /**
          ? * 模仿的alert窗口
          ? */
          ?function showConfirm(info,ok_func,notok_func,ok_str,not_okstr){
          ??alternateWin=new alternateWindow();??
          ??var pBody = alternateWin.init();
          ??alternateWin.initConfirmBody(pBody,info,ok_func,notok_func,ok_str,not_okstr);
          ??alternateWin.type="confirm";
          ?}
          ?/**
          ? * 作用:初始基本信息
          ? */
          ?alternateWindow.prototype.init=function() {
          ??if(alternateFrame==null){
          ???alternateFrame=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")
          ???alternateFrame.style.position="absolute";
          ???document.body.appendChild(alternateFrame);
          ??}else{
          ???alternateFrame.style.visibility="visible";
          ??}
          ??alternateFrame.style.width=screen.availWidth;
          ??alternateFrame.style.height=screen.availHeight;
          ??alternateFrame.style.left=document.body.scrollLeft;
          ??alternateFrame.style.top=document.body.scrollTop;
          ??alternateFrame.name=alternateFrame.uniqueID;

          ??this.win=window.frames[alternateFrame.name];
          ??this.win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div><div></div></body>");
          ??this.win.document.body.style.backgroundColor="transparent";??
          ??document.body.style.overflow="hidden";??
          ??this.pBody=this.win.document.body.children[1];
          ??this.pBg=this.win.document.body.children[0];?
          ??this.hideAllSelect();
          ??this.initBg();

          ??return this.pBody;
          ?}
          ?
          ?/**
          ?* 作用:初始化背景層
          ? */
          ?alternateWindow.prototype.initBg=function(){
          ??with(this.pBg.style){
          ???position="absolute";???
          ???left="0";
          ???top="0";
          ???width="100%";
          ???height="100%";
          ???visibility="hidden";
          ???backgroundColor="#333333";
          ???filter="blendTrans(duration=1) alpha(opacity=30)";
          ??}??
          ??this.pBg.filters.blendTrans.apply();
          ??this.pBg.style.visibility="visible";
          ??this.pBg.filters.blendTrans.play();
          ?}
          ?/**
          ? * 作用:初始化顯示層
          ? */
          ?alternateWindow.prototype.initAlertBody=function(obj,info){
          ??with(obj.style){
          ???position="absolute";
          ???width="400";
          ???height="150";
          ???backgroundColor="#ffffff";???
          ??}
          ??obj.style.left=window.document.body.clientWidth/2-200;
          ??obj.style.top=window.document.body.clientHeight/3;
          ??var str;
          ??str ="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=30>";
          ??str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[提示]</td></tr>";
          ??str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";
          ??str+=info+"</td></tr><tr height=30 bgcolor=#efefef><td align=center>" +
          ?????? "<input type='button' value='確定' id='OK' tabIndex='1'" +
          ?????? " onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
          ?????? " onclick='parent.alternateWin.closeWin()'? tabIndex='2' style='border:solid 1px #666666;background:#cccccc'>" +
          ?????? "</td></tr></table>";
          ??obj.innerHTML=str;
          ??this.win.document.body.all.OK.focus();
          ??this.FocusWhere="OK";
          ?}
          ? alternateWindow.prototype.onKeyDown=function(event,obj){

          ? ?switch(event.keyCode){
          ? ??case 9:
          ? ??? event.keyCode=-1;
          ? ???if(this.type=="confirm"){
          ? ????if(this.FocusWhere=="OK"){
          ? ?????this.win.document.body.all.NO.focus();
          ? ?????this.FocusWhere="NO";
          ? ????}else{
          ? ?????this.win.document.body.all.OK.focus();
          ? ?????this.FocusWhere="OK";
          ? ????}
          ? ???}else if(this.type="alert"){
          ? ????this.win.document.body.all.OK.focus();?
          ? ???}
          ? ??break;
          ? ??case 13:obj.click();break;
          ? ??case 27:this.closeWin();break?;? ??
          ? ?}

          ? }
          ?/**
          ? * 作用:初始化顯示層 conFirm提示層
          ? */
          ?alternateWindow.prototype.initConfirmBody=function(obj,info,ok_func,notok_func,ok_str,notok_str){
          ??with(obj.style){
          ???position="absolute";
          ???width="400";
          ???height="150";
          ???backgroundColor="#ffffff";???
          ??}
          ??if(ok_str==null){
          ???ok_str="確定";
          ??}
          ??if(notok_str==null){
          ???notok_str="取消"?
          ??}
          ??obj.style.left=window.document.body.clientWidth/2-200;
          ??obj.style.top=window.document.body.clientHeight/3;
          ??var str;
          ??str="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=30>";
          ??str+="<td align=left style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>[詢問(wèn)]</td></tr>";
          ??str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: middle;'>";
          ??str+=info+"</td></tr><tr height=30 bgcolor=#efefef><td align=center>" +
          ?????"<input type='button' id='OK'" +
          ?????" onkeyup='parent.alternateWin.onKeyDown(event,this)'"+
          ?????" onclick='parent.alternateWin.closeWin();parent."+ok_func+"();' " +
          ?????" value='"+ok_str+"' style='border:solid 1px #666666;background:#cccccc'>"+
          ?????"&nbsp;&nbsp;&nbsp;<input type='button' value='"+notok_str+"' id='NO'"+
          ?????" onkeydown='parent.alternateWin.onKeyDown(event,this)'"+
          ?????" onclick='parent.alternateWin.closeWin();" +
          ?????" parent."+notok_func+"();' style='border:solid 1px #666666;background:#cccccc'><input type='button' style='width:0px' value=1></td></tr></table>";
          ??obj.innerHTML=str;
          ??this.win.document.body.all.OK.focus();
          ?}

          ?/**
          ? * 作用:關(guān)閉一切
          ? */
          ?alternateWindow.prototype.closeWin=function(){
          ???alternateFrame.style.visibility="hidden";? ??
          ???this.showAllSelect();
          ???document.body.style.overflow="auto";??
          ?}
          ?/**
          ?? * 作用:隱藏所有的select
          ?? */
          ?alternateWindow.prototype.hideAllSelect=function(){
          ?? var obj;
          ?? obj=document.getElementsByTagName("SELECT");
          ?? var i;
          ?? for(i=0;i<obj.length;i++)
          ???obj[i].style.visibility="hidden";
          ?? }
          ?/**
          ? * 顯示所有的select
          ? */?
          ? alternateWindow.prototype.showAllSelect=function(){
          ?? var obj;
          ?? obj=document.getElementsByTagName("SELECT");
          ?? var i;
          ?? for(i=0;i<obj.length;i++)
          ??obj[i].style.visibility="visible";
          ?}

          </script>
          </body>

          posted on 2006-08-09 21:30 黑旋風(fēng) 閱讀(2452) 評(píng)論(2)  編輯  收藏

          評(píng)論:
          # re: 仿163郵箱的彈出框和詢問(wèn)框 2006-08-09 22:42 | 路人
          受益匪淺  回復(fù)  更多評(píng)論
            
          # re: 仿163郵箱的彈出框和詢問(wèn)框 2007-12-07 10:59 | ADASD
          與火狐不兼容,沒(méi)P用  回復(fù)  更多評(píng)論
            

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 偏关县| 治多县| 正定县| 绥宁县| 仁布县| 璧山县| 凤阳县| 花莲县| 建平县| 镇江市| 商河县| 扶绥县| 聂荣县| 称多县| 合作市| 塔城市| 潞城市| 吉木乃县| 瑞昌市| 南乐县| 仙桃市| 南康市| 大城县| 新源县| 汨罗市| 和硕县| 海口市| 东乌| 新乡市| 新竹市| 治县。| 中宁县| 宁远县| 六枝特区| 如东县| 龙山县| 屏山县| 云林县| 江西省| 民县| 罗田县|