코드 복사 코드는 다음과 같습니다. 重写alert <br> var showAlert = function(msg){<br> jAlert(msg, "提示!");<br> }<br> window.alert=showAlert; <p> $.alerts={<br> verticalOffset:-75,horizontalOffset:0,repositionOnResize:true,overlayOpacity:.01,overlayColor:'#FFF',draggable:true,okButton:' OK ',cancelButton:' Cancel ',dialogClass:null,alert:function(message,title,callback){<br> if(title==null)title='Alert';<br> $.alerts._show(title,message,null,'alert',function(result){<br> if(callback)callback(result)<br> })<br> }<br> ,_show:function(title,msg,value,type,callback){<br> $.alerts._hide();<br> $.alerts._overlay('show');<br> $("BODY").append('<div id="popup_container">'+'<h1 id="popup_title"></h1>'+'<div id="popup_content">'+'<div id="popup_message"></div>'+'</div>'+'</div>');<br> if($.alerts.dialogClass)$("#popup_container").addClass($.alerts.dialogClass);<br> var pos=($.browser.msie&&parseInt($.browser.version)<=6)?'absolute':'fixed';<BR> $("#popup_container").css({<BR> position:pos,zIndex:99999,padding:0,margin:0<BR> });<BR> $("#popup_title").text(title);<BR> $("#popup_content").addClass(type);<BR> $("#popup_message").text(msg);<BR> $("#popup_message").html($("#popup_message").text().replace(/\n/g,'<br />'));<br> $("#popup_container").css({<br> minWidth:$("#popup_container").outerWidth(),maxWidth:$("#popup_container").outerWidth()<br> });<br> $.alerts._reposition();<br> $.alerts._maintainPosition(true);<br> switch(type){<br> case'alert':$("#popup_message").after('<div id="popup_panel"><input type="button" value="'+$.alerts.okButton+'" id="popup_ok" /></div>');<br> $("#popup_ok").click(function(){<br> $.alerts._hide();<br> callback(true)<br> });<br> $("#popup_ok").focus().keypress(function(e){<br> if(e.keyCode==13||e.keyCode==27)$("#popup_ok").trigger('click')<br> });<br> break<br> };<br> if($.alerts.draggable){<br> try{<br> $("#popup_container").draggable({<br> handle:$("#popup_title")<br> });<br> $("#popup_title").css({<br> cursor:'move'<br> })<br> }<br> catch(e){}<br> }<br> }<br> ,_hide:function(){<br> $("#popup_container").remove();<br> $.alerts._overlay('hide');<br> $.alerts._maintainPosition(false)<br> }<br> ,_overlay:function(status){<br> switch(status){<br> case'show':$.alerts._overlay('hide');<br> $("BODY").append('<div id="popup_overlay"></div>');<br> $("#popup_overlay").css({<br> 위치:'절대',zIndex:99998,상단:'0px',왼쪽:'0px',너비:'100%', 높이:$(document).height(),배경:$.alerts.overlayColor,opacity:$.alerts.overlayOpacity<br> });<br> break;<br> 케이스'hide':$("#popup_ 오버레이 ").remove();<br> break<br> }<br> }<br> ,_reposition:function(){<br> var top=(($(window).height() 2 ) - ( $("#popup_container").outerHeight() /2)) $.alerts.verticalOffset;<br> var left=(($(window).width()/ 2) - ($("#popup_container"). externalWidth() /2)) $.alerts.horizontalOffset;<br> if(top if(left if($.browser.msie&&parseInt( $.browser.version)<=6)top=top $(window).scrollTop();<br> $("#popup_container").css({<br> 상단: 상단 'px', 왼쪽:왼쪽 'px'<br> });<br> $("#popup_overlay").height($(document).height())<br> }<br> ,_maintainPosition:function(status){<br> 만약 ($.alerts.repositionOnResize){<br> 스위치(상태){<br> 케이스 true:$(window).bind('resize',function(){<br> $.alerts._re 위치()<br> });<br> break;<br> case false:$(window).unbind('resize');<br> break<br> } <br> }<br> }<br> };<br> jAlert=기능(메시지,제목,콜백){<br> $.alerts.alert(메시지,제목,콜백)<br> }</p> <p> $(function(){alert("안녕하세요!")})<br> <br> #popup_container{font-family:Arial,sans-serif; 글꼴 크기:12px;최소 너비:300px;최대 너비:600px;배경:#FFF;테두리:단색 5px #999;색상:#000;-moz-border-radius:5px;-webkit-border-radius :5px;border-radius:5px;}#popup_title{font-size:14px;font-weight:bold;text-align:center;line-height:1.75em;color:#666;배경:#CCC url(이미지 /title.gif) 상단 반복-x;border:solid 1px #FFF;border-bottom:solid 1px #999;cursor:default;padding:0em;margin:0em;}#popup_content{배경:16px 16px 반복되지 않는 URL (images/info.gif);padding:1em 1.75em;margin:0em;}#popup_content.alert{Background-image:url(images/info.gif);}#popup_message{padding-left:48px;}#popup_panel {text-align:center;margin:1em 0em 0em 1em;}#popup_prompt{margin:.5em 0em;}<br>