• 重寫一下js的alert函數


    $.Alert={
    	verticalOffset:-75,horizontalOffset:0,
    	alert:function(msg,callback){
    		$.Alert._show(msg,'alert',function(result){if(callback)callback(result)})
    	}
    	,_show:function(msg,type,callback){
    		$.Alert._hide();
    		$.Alert._overlay('show');
    		$("BODY").append('<div id="popup_container" style="font-family:Arial,sans-serif;line-height:25px;font-size:12px;min-300px;max-600px;border:1px solid #ddd;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background-color:#fff"><div id="popup_content" style="margin:0;padding:10px"><div id="popup_message"></div></div></div>');
    		//var pos=($.browser.msie&&parseInt($.browser.version)<=6)?'absolute':'fixed';
    		var pos='fixed';
    		$("#popup_container").css({position:pos,zIndex:99999,padding:0,margin:0});
    		$("#popup_message").html(msg.replace(/
    /g,'<br>'));
    		//$("#popup_message").html($("#popup_message").text().replace(/
    /g,'<br />'));
    		$("#popup_container").css({minWidth:$("#popup_container").outerWidth(),maxWidth:$("#popup_container").outerWidth()});
    		$.Alert._creat();
    		$(window).bind('resize',function(){$.Alert._creat()});
    		if(type=='alert'){
    			$("#popup_message").after('<div style="text-align:center;margin-top:20px"><button id="popup_ok" style="70px;border:1px solid #444;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px">確認</button></div>');
    			$("#popup_ok").click(function(){$.Alert._hide();callback(true)});
    			$("#popup_ok").focus().keypress(function(e){if(e.keyCode==13||e.keyCode==27)$("#popup_ok").trigger('click')});
    		}
    	}
    	,_hide:function(){
    		$("#popup_container").remove();
    		$.Alert._overlay('hide');
    		$(window).unbind('resize');
    	}
    	,_overlay:function(status){
    		switch(status){
    			case'show':$.Alert._overlay('hide');$("BODY").append('<div id="popup_overlay"></div>');$("#popup_overlay").css({position:'absolute',zIndex:99998,top:'0px',left:'0px','100%',height:$(document).height(),backgroundColor:'#000',opacity:0.7});break;
    			case'hide':$("#popup_overlay").remove();break
    		}
    	}
    	,_creat:function(){
    		var top=(($(window).height()/2) - ($("#popup_container").outerHeight()/2))+$.Alert.verticalOffset;
    		var left=(($(window).width()/2) - ($("#popup_container").outerWidth()/2))+$.Alert.horizontalOffset;
    		if(top<0)top=0;
    		if(left<0)left=0;
    		//if($.browser.msie&&parseInt($.browser.version)<=6)top=top+$(window).scrollTop();
    		$("#popup_container").css({top:top+'px',left:left+'px'});
    		$("#popup_overlay").height($(document).height())
    	}
    };window.alert=function(msg,callback){$.Alert.alert(msg,callback)};

  • 相关阅读:
    bzoj1878: [SDOI2009]HH的项链
    bzoj1053: [HAOI2007]反素数ant
    bzoj2456: mode
    bzoj2330: [SCOI2011]糖果
    bzoj1050: [HAOI2006]旅行comf
    bzoj1047: [HAOI2007]理想的正方形
    bzoj1968: [Ahoi2005]COMMON 约数研究
    bzoj1046: [HAOI2007]上升序列
    bzoj2440: [中山市选2011]完全平方数
    bzoj1202: [HNOI2005]狡猾的商人
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/7201641.html
Copyright © 2020-2023  润新知