【求助】 能否用别的方法替代showModalDialog??

ldw701 2007-01-29 05:09:31
在苹果的浏览器、火狐浏览器中。。。showModalDialog好像不能正常工作,有没有什么方法可以替代showModalDialog,要求在父页面打开自页面时,如果子页面没有关闭,父页面不能做任何操作,子页面关闭是可以刷新父页面,分不够再加
...全文
848 25 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
ldw701 2007-01-30
  • 打赏
  • 举报
回复
有没有人知道新浪邮箱的哪个是怎么做的啊。。。。。知道的大哥站出来。。。。
分有的是啊。。呜呜
A__ 2007-01-30
  • 打赏
  • 举报
回复
up 学习
ldw701 2007-01-30
  • 打赏
  • 举报
回复
顶上去。。。。。。。
还没有解决
蒋晟 版主 2007-01-30
  • 打赏
  • 举报
回复
you can test to see if window.showModalDialog is defined or not. If it is not defined, set the window.showModalDialog property to a function in your script, which mimics the IE behavior.
szh3210 2007-01-30
  • 打赏
  • 举报
回复
up 学习
qizi82 2007-01-30
  • 打赏
  • 举报
回复
嘿嘿 代码写得比较烂
但是功能还是实现了
还希望大家多给挑挑毛病 呵呵
qizi82 2007-01-30
  • 打赏
  • 举报
回复

var ifm=null;

/*描述:显示提示层*/

function showPop(msg){
if(ifm==null)
{
ifm=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")

if (document.body.scrollHeight>screen.availHeight)
{
ifm.style.height=document.body.scrollHeight;
ifm.style.width=document.body.scrollWidth;
}

else
{
ifm.style.height=screen.availHeight;
ifm.style.width=screen.availWidth;
}

ifm.style.position="absolute";

ifm.style.left=0;
ifm.style.top=0;

ifm.name=ifm.uniqueID;
document.body.appendChild(ifm);
}
else
{
ifm.style.visibility="visible";
}

var win=window.frames[ifm.name];
win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div></body>");
win.document.body.style.backgroundColor="transparent";

document.body.style.overflow="hidden";

var pBody=win.document.body.children[1];
var pBg=win.document.body.children[0];
hideAllSelect();
initBg(pBg);
initBody(pBody,msg);

}

/*描述:初始化背景层*/

function initBg(obj){
with(obj.style){
position="absolute";
left="0";
top="0";
width="100%";
height="100%";
visibility="hidden";
backgroundColor="#333333";
filter="blendTrans(duration=1) alpha(opacity=40)";
}

if (obj.filters.blendTrans.status != 2) {//no playing
obj.filters.blendTrans.apply();
obj.style.visibility="visible";
obj.filters.blendTrans.play();
}
}

/*描述:初始化显示层*/
function initBody(obj,msg){
with(obj.style){
position="absolute";
//width="300";
//height="75";
backgroundColor="#ffffff";
}

var info = getItemsInfoChecked();

if (info != "")
{
var str;
str="<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>";
str+=info;
str+="<tr><td align=center bgcolor=#fdfff3 style='font-size:14px;color:#000000;vertical-align: baseline;'>";
str+="<span style='color:red;'>"+msg+"</span><br><button style='BACKGROUND-COLOR: #cccccc; BORDER: #000000 1px solid; font-weight:bold; HEIGHT:20px; Cursor:HAND' onclick='parent.post();'>提 交</button>  ";
str+="<button style='BACKGROUND-COLOR: #cccccc; BORDER: #000000 1px solid; font-weight:bold; HEIGHT:20px; Cursor:HAND' onclick='parent.hideFrame()'>修改价格</button></td></tr></table>";
obj.innerHTML=str;
}
else
{
var str;
str="<table border=0 cellpadding=1 cellspacing=1 width=300 bgcolor=#000000>";
str+="<tr><td align=center bgcolor=#fdfff3 style='font-size:14px;color:#000000;vertical-align: baseline;'><br>";
str+="您没有选中任何商品"+"<br><br>";
str+="<button style='BACKGROUND-COLOR: #cccccc; BORDER: #000000 1px solid; font-weight:bold; HEIGHT:20px; Cursor:HAND' onclick='parent.hideFrame()'>返 回</button><br><br></td></tr></table>";
obj.innerHTML=str;
}

obj.style.left = document.body.scrollLeft+(screen.availWidth-obj.clientWidth)/2;
obj.style.top = document.body.scrollTop+(screen.availHeight-obj.clientHeight)/2-90;

}

/*描述:服务器端按钮的事件*/
function post()
{
__doPostBack('btnPost','');
}

/*描述:隐藏 */
function hideFrame(){
ifm.style.visibility="hidden";
showAllSelect();
document.body.style.overflow="auto";

}

/*描述:隐藏该死的select */
function hideAllSelect(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="hidden";
}

function showAllSelect(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="visible";
}


/*描述:获取页面上被勾选的griditem的id集合*/

function getItemsIdChecked()
{
var inputArray;
var r, re, str, strArray; // 声明变量。
var itemIdStrCollection = "";

re = /^DataGrid1__.*_chkSel$/; // 创建正则表达式模式。

inputArray = document.getElementsByTagName("input");

for (var i=0; i<inputArray.length; i++)
{
obj = inputArray[i];

r = obj.id.match(re);

if (r && obj.checked)
{
itemIdStrCollection += obj.id+",";
}
}
return itemIdStrCollection;

}

/*描述:每一个被勾选的griditem重新生成一个tr*/
function getItemsInfoChecked()
{
var info = "";
var itemIdStrCollection = getItemsIdChecked();

var itemIdArray = itemIdStrCollection.split(",");

for (var i=0; i<itemIdArray.length-1; i++)
{
itemIdPrefix = itemIdArray[i].substr(0,itemIdArray[i].length-6);
hlkProductName_Id = itemIdPrefix + "hlkProductName";
txtMerchantPrice_Id = itemIdPrefix + "txtMerchantPrice";


info +="<tr><td align=left bgcolor=#fdfff3 style='height:12px;border:0px;font-size:14px;color:#000000;vertical-align: baseline;'>商品:"
+document.getElementById(hlkProductName_Id).innerText
+"    销售价格:<span style='color:red;'>"
+document.getElementById(txtMerchantPrice_Id).value
+"</span></td></tr>";
}
return info;
}

yyw84 2007-01-30
  • 打赏
  • 举报
回复
用一个顶层div遮住下面的控件, 再建一个比它顶层的div模拟一个窗口
kingtsui 2007-01-29
  • 打赏
  • 举报
回复
建议使用 div+css
752 2007-01-29
  • 打赏
  • 举报
回复
mark
cpp2017 2007-01-29
  • 打赏
  • 举报
回复
可以刷新. window.opener.location.href = window.opener.location.href ff下也可用.
ldw701 2007-01-29
  • 打赏
  • 举报
回复
我看了一下sina.com.cn的邮箱里面就有这个功能,不知道他是怎么实现的,删除邮件的时候可以禁用父窗口
ldw701 2007-01-29
  • 打赏
  • 举报
回复
TO:cpp2017(慕白兄)

用window.open好像不能刷新父窗口吧,刷新父窗口是必须的,不能抹掉
lizhizhe2000 2007-01-29
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ޱĵ</title>
<script language="JavaScript">
<!--
var lwindow;
function LockWindow(){
var div = document.createElement("DIV");
div.id = "MzLockWindow_"+"_"+new Date().getTime();

with(div.style)
{
zIndex = 10000;
top = "0px";
left = "0px";
width = "100%";
height = "100%";
border = "none";
// display = "none";
margin = padding = 0;
position = "absolute";
backgroundColor = "#999999";
backgroundImage = "url(/transparent.gif)";
duration=1000;
}
document.body.insertBefore(div, document.body.firstChild);
_hide("SELECT");
_hide("OBJECT");
_hide("IFRAME");
_Resize(div);
document.getElementById("Layer1").style.visibility="visible";
return div;
}

function _Resize(obj)
{
obj.style.width = "100%";
obj.style.height= "100%";

var bodyCW, bodyCH; if(window.innerWidth) bodyCW=window.innerWidth;
else if(document.documentElement&&document.documentElement.clientWidth)
bodyCW=document.documentElement.clientWidth;
else if(document.body) bodyCW=document.body.clientWidth;

if(window.innerHeight) bodyCH=window.innerHeight;
else if(document.documentElement&&document.documentElement.clientHeight)
bodyCH=document.documentElement.clientHeight;
else if(document.body) bodyCH=document.body.clientHeight;

setTimeout(function() //for ie;
{
bodyCW = Math.max(document.body.scrollWidth, bodyCW);
bodyCH = Math.max(document.body.scrollHeight, bodyCH);
obj.style.width = bodyCW +"px";
obj.style.height= bodyCH +"px";
}, 1);
}
function _show(TagName)
{
var s = document.getElementsByTagName(TagName);
for(var i=0, n=s.length; i<n; i++)
{
s[i].style.visibility=s[i].getAttribute("att_MzLockWindow_v");
s[i].removeAttribute("att_MzLockWindow_v");
}
};
function _hide(TagName)
{
var s = document.getElementsByTagName(TagName);
for(var i=0, n=s.length; i<n; i++)
{
s[i].setAttribute("att_MzLockWindow_v", s[i].style.visibility, 0);
s[i].style.visibility = "hidden";
}
};
function UnlockWindow(obj){
if (obj){
document.body.removeChild(obj);
_show("SELECT");
_show("OBJECT");
_show("IFRAME");
document.getElementById("Layer1").style.visibility="hidden";
}
}
//-->
</script>
</head>

<body>
<form name="form1" method="post" action="">
<p>  </p>
<iframe src="b.htm"></iframe>
<p> </p>
<div id="Layer1" style="position:absolute; width:300px; height:115px; z-index:10001; left: 50px; top: 87px; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000; visibility: hidden;">
<input type="button" name="Submit" value="unlock" onClick="UnlockWindow(lwindow);">
</div>
<p> </p>
<p> </p>
<p>
<input type="button" name="Submit" value="lock" onClick="lwindow=LockWindow();">
</p>
<div id="Layer2" style="position:absolute; width:200px; height:115px; z-index:1; left: 250px; top: 73px; background-color: #FF0000; layer-background-color: #FF0000; border: 1px none #000000;"></div>
</form>
</body>
</html>
lizhizhe2000 2007-01-29
  • 打赏
  • 举报
回复
可以做个类似于回复效果的层,用于屏避上方层下方的所有东西!
yiyioo 2007-01-29
  • 打赏
  • 举报
回复
用div实现可以啊

但是也会有些问题.如果网页中存在flash.而这个flash又不是透明的
这样在ff下似乎就不行了
EASTENRIVER 2007-01-29
  • 打赏
  • 举报
回复
用div应该是比较好的方式,不知大家是否看过sohu邮箱读取邮件的效果.
cpp2017 2007-01-29
  • 打赏
  • 举报
回复
不禁用父窗口就用window.open
ldw701 2007-01-29
  • 打赏
  • 举报
回复
哪不要禁用父窗口可以实现吗??
要是实现不了,就降低要求。。。。。不管了
郁闷
LifeForCode 2007-01-29
  • 打赏
  • 举报
回复
可以open一个不能失去焦点的窗体,不过要用onblur事件,不知道火狐支持否
加载更多回复(5)

62,244

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧