<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>author:meixx</title>
<script language="javascript">
var pWin=window.open("","");
function initTable(){
pWin.focus();
}
</script>
</head><body onreLoad="initTable()">
ssdfsdf
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>author:meixx</title>
<script language="javascript">
var pWin=window.open("","");
function initTable(){
pWin.focus();
}
</script>
</head><body onreLoad="initTable()">
ssdfsdf
</body>
</html>
var pWin=window.open("",""); // 问题在这里
function initTable(){
pWin.focus();
}应该给新开窗口加上名字,比如"newWin",这样open时,如果已经open过会自动找已经打开的窗口。
var pWin=window.open("newWin","");
pWin.focus();
问题已不在于能否对应他的窗体.而是怎么样使他的子窗体重新或得焦点并且不是重新加载.
2.模态窗口的关闭
3.模态窗口的传递参数。
4.其他。
1.window.showModalDialog("DialogPage.aspx","newwin","dialogHeight: 200px; dialogWidth: 150px; dialogTop: 458px; dialogLeft: 166px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;");2.window.close();3.传值
ParentPage.aspx:
window.showModalDialog("DialogPage.aspx?para1=aaa¶2=bbb");DialogPage.aspx:
string str1=Request.QueryString["para1"].toString();
string str2=Request.QueryString["para2"].toString();返回值
DialogPage.aspx:
window.returnValue="aaa";ParentPage.aspx:
var str=window.showModalDialog("DialogPage.aspx");4.
aspx页面在showmodeldialog情况下为什么一提交就重新打开一个页面?
showmodaldialog打开的页面中在<head></head>之间加入一行:<base target="_self">
WebForm2.aspx.vb
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "var st=window.showModalDialog('user.aspx?val='+document.all('TextBox1').value);document.all('TextBox1').value=st;return st;")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RegisterStartupScript("key", "<script>window.opener=null;window.close(this);</script>")
End Sub
user.aspx.vb
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents cancel As System.Web.UI.WebControls.Button
Protected WithEvents ok As System.Web.UI.WebControls.Button
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim str As String
If Not IsPostBack Then
str = Request.QueryString("val")
TextBox1.Text = str
End If
End Sub
Private Sub cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel.Click
RegisterStartupScript("key", "<script>window.returnValue='null';window.opener=null;window.close(this);</script>")
End Sub
Private Sub ok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ok.Click
RegisterStartupScript("key", "<script>window.returnValue=document.all('TextBox2').value;window.opener=null;window.close(this);</script>")
End Sub
to goody9807() :
现在的情况是非模式窗口问题
<head>
<SCRIPT LANGUAGE="JavaScript">
function openwin()
{
OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
//写成一行
OpenWindow.document.write("<TITLE>例子</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
OpenWindow.document.write("<h1>Hello!</h1>")
OpenWindow.document.write("New window opened!")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
</SCRIPT>
</head>
<body>
<a href="#" onclick="openwin()">打开一个窗口</a>
<input type="button" onclick="openwin()" value="打开窗口">
</body>
</html>
var x
function test(){
x=window.open("vv.html");
x.name="KKK";}
function test2(){
x=window.open("","KKK");
x.focus();
alert(x.location);
}
</script>
<input type=button onclick="test();" value="刷新前打开">
<input type=button onclick="test2();" value="刷新后">
if (parent.ChildWnd == null)
{
parent.ChildWnd = window.open("xxx");
}
parent.ChildWnd.focus();//子窗口关闭时:
opener.parent.ChildWnd = null;
--------IE的工具条上的“刷新”按一下,一样完蛋。
hhjjhjhj(大头)(想变胡萝卜^^) (
说得也是