コードをコピー コードは次のとおりです: 重写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> position:'absolute',zIndex:99998,top:'0px',left:'0px',width:'100%', height:$(document).height(),background:$.alerts.overlayColor,opacity:$.alerts.overlayOpacity<br> });<br> Break;<br> case'hide':$("#popup _オーバーレイ").remove();<br> Break<br> }<br> }<br> ,_reposition:function(){<br> var top=(($(window).height()/ ) - ( $("#popup_container").outerHeight() /2)) $.alerts.verticalOffset;<br> var left=(($(window).width()/ 2) - ($("#popup_container"). innerWidth() /2)) $.alerts.horizontalOffset;<br> if(top if(left if($.browser.msie&&parseInt( $.browser.version)<=6)top=top $(window).scrollTop();<br> $("#popup_container").css({<br> top:top 'px',left:left 'px'<br> });<br> $("#popup_overlay").height($(document).height())<br> }<br> ,_maintainPosition:function(status){<br>もし($.alerts.repositionOnResize){<br> switch(status){<br> case true:$(window).bind('resize',function(){<br> $.alerts ._reposition()<br> });<br> Break;<br> case false:$(window).unbind('resize');<br> Break<br> }<br> }<br> }<br> };<br> jAlert=function(message,title,callback){<br> $.alerts.alert(message,title,callback)<br> }</p> <p> $(function(){alert("hello word!")})<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;background:#CCC url(画像/title.gif) トップリピート-x;border:solid 1px #FFF;border-bottom:solid 1px #999;cursor:default;padding:0em;margin:0em;}#popup_content{background: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>