关于showModalDialog的问题,太头痛了

边城狂人 2004-11-24 02:53:52
我有三个页面,a.htm, b.htm 和 c.htm
其中,a.htm 中,通过 showModalDialog 打开了 b.htm
然后,如果是返回一般的属性值,就用 b.htm 的 window.returnValue 直接返回了
如果需要返回一些高级属性值,那在 modaldialog 里就需要从 b.htm 跳转到 c.htm,再从 c.htm 中选择属性值,用 window.returnValue 来返回

现在的问题是,从 b.htm 链接去 c.htm 的时候,它会自动打开一个新的窗口,而不是在当前的 modalDialog 里打开。加 _self 也没有用,

请大家帮我想想办法。
...全文
165 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
JK_10000 2004-11-24
  • 打赏
  • 举报
回复
方法1:
在b.htm的head里加上这句:
<base target="_self"/>

方法2:
在这个页面的外面套一个iframe


a.htm:
--------------------------
functoin testFun()
{
var DialogArgument=new Array();
DialogArgument["src"]=homeUrl+"b.htm";
DialogArgument["title"]="b.htmTitle";
var a=showModalDialog("DialogFrame.htm",DialogArgument,"status:no;resizable:no;help:no;dialogHeight:350px;dialogWidth:600px;");
alert("return value is "+a);
}


DialogFrame.htm
--------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<script language=javascript>

var DialogArgument=window.dialogArguments;
if (DialogArgument!=null) document.write("<title>"+DialogArgument.title+"</title>");
else document.write("<title>Dialog</title>");
</script>
<title>Dialog</title>
</head>

<body leftMargin=0 rightMargin=0 topMargin=0 bottomMargin=0 onload="initFun();">
<iframe width=100% height=100% id=dialogIframe></iframe>
</body>

</html>
<script language=javascript>

function initFun()
{

if (DialogArgument!=null) document.all.dialogIframe.src=DialogArgument.src;
else alert('Sorry! Perhaps you are use this page wrongly');
}


</script>




b.htm;c.htm
--------------------------
function OkFun()
{
top.returnValue="OK";
top.close();

}
Yansharp 2004-11-24
  • 打赏
  • 举报
回复
没有太明白你的意思。
不过showModalDialog 的窗口确实不能在自身打开一个新的窗口。

有时候问题解决不了,应该想想,是不是解决问题的思路不对。

不好意思,帮不了你,只能说说我的想法

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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