重写window.confirm,页面刷新问题
将window.confirm用一个div代替后,对一个按钮执行一个回调函数,发现在页面上执行的被执行的函数参数始终为第一次的值,页面整体刷新后可以传入新值,要变化传入的参数值,就还需要刷新页面,有没有办法,每次不用刷新整个页面的
=======================confirm 封装后的代码===============================
function fn_confirm(msg){
if($('#temp_Over_Lay_confirm').length==0)
{
$('<div></div>')
.appendTo('body')
.attr('id','temp_Over_Lay_confirm')
.css({
'position':'absolute',
'left':'0px',
'top':'0px',
'background-color':'#000000',
'opacity':'0.2',
'filter':'alpha(opacity=20)',
'width':'100%',
'height':'100%',
'z-index':'12000010'
})
.append('<iframe src="about:blank" height="100%" width="100%"></iframe>')
.append('<div style="position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:12000011;background-color:#000000;opacity:0.2;filter:alpha(opacity=20);"></div>');
}
else
{
$('#temp_Over_Lay_confirm').show();
}
var strInfo = msg||'';
if($('#temp_op_container_confirm').length==0)
{
$('<div></div>')
.appendTo('body')
.html(
' <style type="text/css">'+
' .ichTop{ background:url(./images/ch_ich_top_bg1.gif) no-repeat left top; }'+
' .ichTopInt{height:26px;line-height:26px;background:url(./images/ch_ich_top_bg2.gif) no-repeat right top;padding:0 10px;}'+
' h1.ichhead{ color:#FFF; line-height:26px;font-weight:normal; font-size:12px;background:url(./images/ch_ich_top_bg3.gif) repeat-x left top;}'+
' h1.ichhead span{ float:right; margin-top:5px; height:15px; width:15px; cursor:pointer; background:url(./images/ch_ridi_ico.gif) no-repeat left top }'+
' h1.ichhead span.sp01{ background:url(./images/ch_ico_rBhelp.gif) no-repeat left 1px; margin-right:10px; line-height:20px; height:20px; width:auto; padding-left:20px;margin-top:4px;}'+
' .ichText{ margin-left:0; background:#FFF; padding:1px; border:2px solid #3182CE; text-align:center}'+
' </style>'+
' <div style="padding-top:0px;border: solid 1px #81ADE8; padding:1px; background:#fff;">'+
' <div id="tempDragHeaderconfirm" class="ichTop" style="cursor:move;display:block;">'+
' <div class="ichTopInt">'+
' <h1 class="ichhead">'+
' <span id="spanColseconfirm" title="关闭"></span>'+
' <font id="__confirmTitle">确认提示</font>'+
' </h1>'+
' </div>'+
' </div>'+
' <div id="divinfoconfirm" style="margin:10px;word-wrap: break-word; word-break: break-all;">' + (strInfo+'').replace('\n','<br/>') +'</div>'+
' <div style="margin:auto;margin-top:10px;margin-bottom:8px;text-align:center;"><input type="image" alt="确定" id="makeconfirm" src="./images/ch_wrong_ico1.gif" style="border:0px;cursor:pointer;margin:auto;" /> <input type="image" alt="取消" id="btncloseconfirm" src="./images/ch_cancel.gif" style="border:0px;cursor:pointer;margin:auto;" /></div>'+
' </div>')
.attr({'id':'temp_op_container_confirm','class':'rightBox'})
.css({
'width':'300px',
'left':(($('body')[0].scrollWidth-400)/2+'px'),
'top':'200px',
'background-color':'#d0d0d0',
'position':'absolute',
'z-index':'12000012',
'display':''
});
$('#btncloseconfirm').click(function(){
$('#temp_op_container_confirm').hide();
$('#temp_Over_Lay_confirm').hide();
return true;
});
$('#makeconfirm').click(function(){
$('#temp_op_container_confirm').hide();
$('#temp_Over_Lay_confirm').hide();
//eval(fun_name);
return false;
});
$('#spanColseconfirm').mousedown(function(){
$('#temp_op_container_confirm').hide();
$('#temp_Over_Lay_confirm').hide();
goback(arguments[0]);
});
new dragMove(document.getElementById('tempDragHeaderconfirm'),document.getElementById('temp_op_container_confirm'),document.getElementById('temp_Over_Lay_confirm'));
} else {
$('#temp_op_container_confirm').show();
$('#divinfoconfirm').html((strInfo + '').replace('\n', '<br/>'));
$('#__confirmTitle').html('确认提示');
$('#temp_op_container_confirm').width(300);
}
$('#btncloseconfirm').focus();
return false;
}
//var makecofirm = window.confirm;
window.confirm = function() {
// if (arguments.length == 2 && arguments[1]) { fn_confirm(arguments[0],arguments[1]); return; }
// makecofirm(arguments[0]);
return fn_confirm(arguments[0]);
}
===========================confirm 封装完毕=======================================
===========================页面前端调用confirm====================================
function test(resid){
confirm("confirm重写","c_del_rec_sure("+resid+")");
}
function c_del_rec_sure(resid){
try{
windown.status(resid);
console.log("chirld="+resid);
}catch(e){
alert(e);
}
}
==========================页面调用完毕===========================================
chirld=0(传入参数resid=0)
chirld=0(传入参数resid=1)
.....
chirld=0(传入参数resid=3)