后台代码中弹出js自定义窗口在IE中出错
在后台代码中使用这个弹出窗口Page.ClientScript.RegisterClientScriptBlock(Page.ClientScript.GetType(), "ok ", "_error_msg_show(\ " " + msg + "\ "); ", true);
IE中打运行时会提示无法打开Internet站点
firefox运行正常
我想原因可能是当打开弹出窗口时.ie中原窗口还没有加载完成.导致ie报错.请各位高手帮忙......
其中_error_msg_show源代码如下.是一个js写的
function dialog()
{
var titile = ' ';
var auto = 'y ';
var width = 240;
var height = 120;
var src = " ";
var path = "/images/ ";
var sFunc = ' <input id= "dialogOk " type= "button " value= " 确 定 " onclick= "new dialog().reset(); " /> <input id= "dialogCancel " type= "button " value= " 取 消 " onclick= "new dialog().reset(); " /> ';
var sClose = ' <input type= "image " id= "dialogBoxClose " onclick= "new dialog().reset(); " src= " ' + path + 'close_blue.gif " border= "0 " width= "16 " height= "16 " align= "absmiddle " /> ';
var sBody = '\
<table id= "dialogBodyBox " border= "0 " align= "center " cellpadding= "0 " cellspacing= "6 " width= "100% "> \
<tr height= "10 "> <td colspan= "4 "> </td> </tr> \
<tr> <td colspan= "4 " align= "center "> \
<div id= "dialogMsgDiv " style= "text-align:center "> <div id= "dialogMsg " style= "font-size:12px;line-height:180%; "> </div> </div> \
</td> </tr> \
<tr> <td id= "dialogFunc " colspan= "4 " align= "center "> ' + sFunc + ' </td> </tr> \
<tr height= "5 "> <td colspan= "4 " align= "center "> </td> </tr> \
</table> \
';
var sIfram = '\
<iframe id= "dialogIframBG " name= "dialogIframBG " frameborder= "0 " marginheight= "0 " marginwidth= "0 " hspace= "0 " vspace= "0 " scrolling= "no " style= "position:absolute;z-index:8;display:none; "> </iframe> \
';
var sBox = '\
<div id= "dialogBox " style= "border:1px solid #1e4775;display:none;z-index:10;width: '+width+ 'px; "> \
<table width= "100% " border= "0 " cellpadding= "0 " cellspacing= "0 "> \
<tr height= "24 " bgcolor= "#6795B4 "> \
<td> \
<table onselectstart= "return false; " style= "-moz-user-select:none; " width= "100% " border= "0 " cellpadding= "0 " cellspacing= "0 " style= "background-color:#5499dc; height:25px; border-top:1px solid #92c3ec; "> \
<tr> \
<td width= "6 " height= "24 "> </td> \
<td id= "dialogBoxTitle " onmousedown= "new dialog().moveStart(event, \ 'dialogBox\ ') " style= "color:#fff;cursor:move;font-size:12px;font-weight:bold; "> </td> \
<td id= "dialogClose " width= "20 " align= "right " valign= "middle "> \
' + sClose + '\
</td> \
<td width= "6 "> </td> \
</tr> \
</table> \
</td> \
</tr> \
<tr id= "dialogHeight " style= "height: ' + height + ' " valign= "top "> \
<td id= "dialogBody " bgcolor= "#ffffff "> ' + sBody + ' </td> \
</tr> \
</table> </div> \
<div id= "dialogBoxShadow " style= "display:none;z-index:9; "> </div> \
';
var sBG = '\
<div id= "dialogBoxBG " style= "position:absolute;top:0px;left:0px;width:100%;height:100%; "> </div> \
';
this.show = function()
{
this.middle( 'dialogBox ');
if ($( 'dialogIframBG '))
{
$( 'dialogIframBG ').style.top = $( 'dialogBox ').style.top;
$( 'dialogIframBG ').style.left = $( 'dialogBox ').style.left;
$( 'dialogIframBG ').style.width = $( 'dialogBox ').offsetWidth;
$( 'dialogIframBG ').style.height = $( 'dialogBox ').offsetHeight;
$( 'dialogIframBG ').style.display = 'block ';
}
this.shadow();
}
this.reset = function()
{
this.close();
}
this.close = function()
{
if ($( 'dialogIframBG '))
{
$( 'dialogIframBG ').style.display = 'none ';
}
$( 'dialogBox ').style.display= 'none ';
$( 'dialogBoxBG ').style.display= 'none ';
$( 'dialogBoxShadow ').style.display = "none ";
$( 'dialogBody ').innerHTML = sBody;
}
this.html = function(_sHtml)
{
$( "dialogBody ").innerHTML = _sHtml;
this.show();
}
this.init = function(big_msg)
{
$( 'dialogCase ') ? $( 'dialogCase ').parentNode.removeChild($( 'dialogCase ')) : function(){};
var oDiv = document.createElement( 'span ');
oDiv.id = "dialogCase ";
if ( 'yes ' == big_msg)
{
oDiv.innerHTML = sBG + sBox;
}
else
{
if (!is_opera_d)
{
oDiv.innerHTML = sBG + sIfram + sBox;
}
else
{
oDiv.innerHTML = sBG + sBox;
}
}
document.body.appendChild(oDiv);
$( 'dialogBoxBG ').style.height = document.body.scrollHeight;
}
this.button = function(_sId, _sFuc)
{
if($(_sId))
{
$(_sId).style.display = ' ';
if($(_sId).addEventListener)
{
if($(_sId).act)
{
$(_sId).removeEventListener( 'click ', function(){eval($(_sId).act)}, false);
}
$(_sId).act = _sFuc;
$(_sId).addEventListener( 'click ', function(){eval(_sFuc)}, false);
}
else
{
if($(_sId).act)
{
$(_sId).detachEvent( 'onclick ', function(){eval($(_sId).act)});
}
$(_sId).act = _sFuc;
$(_sId).attachEvent( 'onclick ', function(){eval(_sFuc)});
}
}
}
this.shadow = function()
{
var oShadow = $( 'dialogBoxShadow ');
var oDialog = $( 'dialogBox ');
oShadow[ 'style '][ 'position '] = "absolute ";
oShadow[ 'style '][ 'background ']= "#000 ";
oShadow[ 'style '][ 'display ']= " ";
oShadow[ 'style '][ 'opacity ']= "0.2 ";
oShadow[ 'style '][ 'filter '] = "alpha(opacity=20) ";
oShadow[ 'style '][ 'top '] = oDialog.offsetTop + 6;
oShadow[ 'style '][ 'left '] = oDialog.offsetLeft + 6;
oShadow[ 'style '][ 'width '] = oDialog.offsetWidth;
oShadow[ 'style '][ 'height '] = oDialog.offsetHeight;
}
this.open = function(_sUrl, _sMode)
{
this.show();
if(!_sMode || _sMode == "no " || _sMode == "yes "){
var openIframe = " <iframe width= '100% ' height= '100% ' name= 'iframe_parent ' id= 'iframe_parent ' src= ' " + _sUrl + " ' frameborder= '0 ' scrolling= ' " + _sMode + " '> </iframe> ";
$( "dialogBody ").innerHTML = openIframe;
}
}
this.showWindow = function(_sUrl, _iWidth, _iHeight, _sMode)
{
var oWindow;
var sLeft = (screen.width) ? (screen.width - _iWidth)/2 : 0;
var iTop = -80 + (screen.height - _iHeight)/2;
iTop = iTop > 0 ? iTop : (screen.height - _iHeight)/2;
var sTop = (screen.height) ? iTop : 0;
if(window.showModalDialog && _sMode == "m "){
oWindow = window.showModalDialog(_sUrl, " ", "dialogWidth: " + _iWidth + "px;dialogheight: " + _iHeight + "px ");
} else {
oWindow = window.open(_sUrl, ' ', 'height= ' + _iHeight + ', width= ' + _iWidth + ', top= ' + sTop + ', left= ' + sLeft + ', toolbar=no, menubar=no, scrollbars= ' + _sMode + ', resizable=no,location=no, status=no ');
this.reset();
}
}
..................
}
function _error_msg_show(msg, click, icon, title)
{
click = click ? click : ' ';
icon = icon ? icon : ' ';
title = title ? title : '百晓提示 ';
dg=new dialog();
dg.init();
dg.set( 'src ', get_icon(icon));
dg.set( 'title ', title);
dg.event(msg, click, ' ', click);
}
[解决办法]
看晕了!
帮顶!