window.showModalDialog怎么接收跳转页面的返回值
我在主页面js中调用
var file_path = window.showModalDialog("../a.htm", null, "dialogWidth=450px;dialogHeight=150px;center=yes;status=no");
a.html是用来上传文件的
<form id="form1" method="post" enctype="multipart/form-data" action="b.aspx">
<input id="testId" type="file" name="testName" />
<input id="testSubmit" type="submit" value="上传" />
</form>
b.aspx上传文件
这样问题就来了 我在b.aspx上传文件后的路径怎么传回a.htm或者传回主页面,window.returnValue已经传不回去了 求指导~~~ JavaScript
[解决办法]
你可以在a.html里面放一个iframe来接收上传结果,像这样:
<body>
<form id="form1" method="post" enctype="multipart/form-data" action="b.aspx" target="result">
<input id="testId" type="file" name="testName" />
<input id="testSubmit" type="submit" value="上传" />
</form>
<iframe id="result" style="display:none"></iframe>
</body>
然后在b.aspx中返回下面这段script:
Response.Clear();
Response.Write(@"<script>
var win = window.parent;
win.returnValue = 'xxxxxx';
win.close();
</script>");
Response.End();
[解决办法]
http://www.cnitblog.com/yide/archive/2012/03/13/78074.aspx
[解决办法]
不用这么麻烦,贴给你我的代码
主页:
<script language="javascript" type="text/javascript">
function OpenWeb() {
str = window.showModalDialog('../../Basis/Text/Select.aspx?IsBtain=true', '', 'dialogWidth=900px;dialogHeight=600px;');
document.getElementById('<%=hfSelect.ClientID %>').value = str;
document.getElementById('<%=Button2.ClientID %>').click();
}
</script>
弹出窗口页:
Page.ClientScript.RegisterStartupScript(GetType(), string.Empty, "<script>var arr=[" + rdobtain + "];window.returnValue=arr;window.close();</script>");
应该能看懂吧 很简单的 不用你那么麻烦