如何关闭父onload的弹出窗口 [英] how can i close a pop up from the parent onload

查看:110
本文介绍了如何关闭父onload的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当从主窗口提交表单时,我想要一个弹出窗口

从onclick事件中打开。我有那个工作,现在我怎么能在主窗口后从主窗口关闭弹出窗口

完成加载?在过去的两天里,我一直在绞尽脑汁。这是我一直在测试的父窗口的代码

with。


testfoo.htm只是一个用于测试的空白html页面。 />

< head>

< title>人事信息< / title>

< script language =" javascript" type =" text / javascript">

var newWindow;

// alert(newWindow +" page load");


函数openDialogWin(){

var height =" 300";

var width =" 500";

var x =(screen.width - width)/ 2;

var y =(screen.height - height)/ 2;

var Name = window.name;

//警报(高度+"," +宽度);


features =" height =" + height +",width =" + width +",left ="

+ x +",top =" + y;

feature + =",menubar = no,resizable = no,titlebar = no,scrollbars = no,status = no,toolbar = no,menubar = no,location = no" ;;

var newWindow = window.open(unescape(" /testfoo.htm"),

" newWindow",features);

//alert(newWindow.name +" in openDialogWin");

返回newWindow;

}


函数closeDialogWin( ){

if(newWindow&&!newWindow.closed)

newWindow.close();

}

< / script>


< / head>

< body onLoad =" closeDialogWin();">

< form method =" post">

< input type =" submit"名称= QUOT; FOO" value ="提交"

onclick =" openDialogWin();">

< / form>

< /正文>

< / html>


抱歉格式化...在编辑窗口中看起来没问题。如果

任何人都可以告诉我如何格式化电路板的代码,我会

尽我所能遵守。


提前感谢


jones

when a form is submitted from the main window i want a pop up window
to open from the onclick event. i have that working, now how can i
close the pop up window from the main window after the main window
finishes loading? i''ve been racking my brain on this for the last two
days. here is the code for the parent window that i have been testing
with.

testfoo.htm is just a blank html page used for testing.

<head>
<title>Personnel Information</title>
<script language="javascript" type="text/javascript">
var newWindow;
//alert(newWindow + " page load");

function openDialogWin() {
var height = "300";
var width = "500";
var x = (screen.width - width) / 2;
var y = (screen.height - height) / 2;
var Name = window.name;
//alert(height + ", " + width);

features = "height=" + height + ",width=" + width + ",left="
+ x + ",top=" + y;
features += ",menubar=no,resizable=no,titlebar=no,scrollbars=n o,status=no,toolbar=no,menubar=no,location=no";
var newWindow = window.open(unescape("/testfoo.htm"),
"newWindow", features);
//alert(newWindow.name + " in openDialogWin");
return newWindow;
}

function closeDialogWin() {
if (newWindow && !newWindow.closed)
newWindow.close();
}
</script>

</head>
<body onLoad="closeDialogWin();">
<form method="post">
<input type="submit" name="foo" value="Submit"
onclick="openDialogWin();">
</form>
</body>
</html>

sorry about the formatting... it looks ok in the editing window. if
anyone can clue me in on how to format the code for the boards, i''ll
do my best to comply.

thanks in advance

jones

推荐答案

文章< 94 **** **********************@posting.google.com>,
ja ******** @ hotmail.com 启发我们...
In article <94**************************@posting.google.com >,
ja********@hotmail.com enlightened us with...
当从主窗口提交表单我想要一个弹出窗口
从onclick事件打开。我有那个工作,现在我怎么能在主窗口完成加载后从主窗口关闭弹出窗口?在过去的两天里,我一直在绞尽脑汁。这是我一直在测试的父窗口的代码。


你重新声明了newWindow,所以你做的是创建一个本地var和

global保持不变。

功能+ =",menubar = no,resizable = no,titlebar = no,scrollbars = no,status = no,toolbar = no,menubar = no, location = no" ;;
var newWindow = window.open(unescape(" /testfoo.htm"),
" newWindow",features);
when a form is submitted from the main window i want a pop up window
to open from the onclick event. i have that working, now how can i
close the pop up window from the main window after the main window
finishes loading? i''ve been racking my brain on this for the last two
days. here is the code for the parent window that i have been testing
with.

You redeclared newWindow, so what you did was create a local var and the
global is unchanged.
features += ",menubar=no,resizable=no,titlebar=no,scrollbars=n o,status=no,toolbar=no,menubar=no,location=no";
var newWindow = window.open(unescape("/testfoo.htm"),
"newWindow", features);



带走那个var。

newWindow = ...


你不需要从该函数返回newWindow或者,因为

无论如何都没有抓到它。


-

-

~kaeli 〜

没有一丝证据支持生命是严重的概念。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace



Take away that "var".
newWindow = ...

You don''t need to return newWindow from that function either, since
nothing caught it anyway.

--
--
~kaeli~
Not one shred of evidence supports the notion that life is
serious.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


我删除了var ;,但现在我得到一个错误:''newWindow''是

undefined"。另外,我在

父母和孩子的窗户之间来回传递''newWindow'。


jones


***通过开发人员指南 http://www.developersdex.com 发送** *

不要只是参加USENET ......获得奖励!
i removed the "var", but now i am getting an "Error: ''newWindow'' is
undefined". also, i am passing ''newWindow'' back and forth between the
parent and child windows.

jones

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


我删除了var,但是我我仍然遇到同样的问题 -

newWindow未定义,并且没有被closeDialogWin

函数关闭。


jones


***通过开发人员指南 http://发送www.developersdex.com ***

不要只参加USENET ......获得奖励!
i removed the "var", but i''m still running into the same problem -
newWindow is undefined and is not being close by the closeDialogWin
function.

jones

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


这篇关于如何关闭父onload的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆