我使用了一个网页对话框,在我使用结束后,我想通过一个"确定"按忸结束此对话框,并同时将值传递给父窗口,使得父窗口的一个TextBox控件显示出我传递的值.
我使用了
<script language="javascript">
parent.docuement.all.TextBox1.value="adfasdf";
</script>
但是每次运行的结果总是本窗口的一个控件TextBox1控件得到该值,父窗口不变
请问怎么实现这个呀求教大家了
帮帮忙
万分感谢!!!
我使用了
<script language="javascript">
parent.docuement.all.TextBox1.value="adfasdf";
</script>
但是每次运行的结果总是本窗口的一个控件TextBox1控件得到该值,父窗口不变
请问怎么实现这个呀求教大家了
帮帮忙
万分感谢!!!
报错
opener.document为空或者不是对象呀
self.opener.document为空或者不是对象
例如:window.open("childform.aspx?text=TextBox1");子窗体:
<script language="javascript">
var txt=eval("self.opener.document.<%=Request["text"]%>");
txt.value=="adfasdf";
window.close();
</script>
opener.Form1.TextBox1.value="aaa";
swordragon(古道热肠)
你的方法我已经试过了
没有用
<head>
<title></title>
<script language='javascript'>
function dd()
{
var answer=window.prompt("What's your name?","");
if(answer)
{
mytxt.value=answer;
}
} </script>
</head><body>
<input type="button" value="dd" name="mybtn" onclick="dd()">
<input type="text" name="mytxt">
</body>
</html>
我的父窗口中使用了
<iframe></iframe>分栏结构
其中<iframe name="right" align="top" marginWidth="0" marginHeight="0" src="document.aspx" frameBorder="0" width="100%" scrolling="no" height="845" style="WIDTH: 112.36%; HEIGHT: 845px"></iframe>
TextBox1位于document.aspx文件中
父窗口:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session["get"] != null && Session["get"].ToString() != "")
{
this.TextBox1.Text = Session["get"].ToString();//得到子窗口返回的值
}
}
private void Button1_Click(object sender, System.EventArgs e)//弹出子窗口
{
Response.Write("<script language='javascript'>\r\n");
Response.Write("var intReturn = showModalDialog('WebForm2.aspx ','','dialogWidth:450px;dialogHeight:230px;center:Yes');\r\n");//弹出一个新窗口
/*通过判断返回值决定传递哪些值*/
Response.Write("if(intReturn == 1)\n\r");
Response.Write("self.location=\"parent.aspx" + "\";\n\r");
Response.Write("</");
Response.Write("script>");
}
子窗口:
private void Button1_Click(object sender, System.EventArgs e)//子窗口的确定事件
{
Session["get"] = this.TextBox1.Text;//设置你要返回的值,保存在Session中 /*关闭子窗口*/
Response.Write ("<script language=\"javascript\">\n\r");
Response.Write("window.returnValue=1;\n\r");
Response.Write("window.close();\n\r");
Response.Write("</");
Response.Write("script>");
}
我觉得可以直接使用脚本写出来的呀
不需要重新定位的
但是非常感谢 stoneallen
window.returnValue="kasdfjkasdfj";父窗体:
var retval = window.showModalDialog("childform.aspx", "", "status:off;dialogHeight:520px;dialogWidth:580px;");
document.frames["right"].document.getElementById("TextBox1").value=retval;