By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,833 Members | 2,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,833 IT Pros & Developers. It's quick & easy.

need to close main window on child opens succesfully

P: n/a
Hi ,

I need to close main window, once the child window succesfully opens
else main window to remain. In my case when I close the main window
immediately after the "window.open()" as mentioned below, both the main
and child disappears(this is due to pop up blocker) disappears
suddenly. I want to make the browser know if pop up blocks the child
window(in case).

help me how to check the child window opened successfuly or not, on
successful closing the main window.
//main window
function onLoad(){
var feat =
'toolbar=no,directories=no,location=no,status=no,m enubar=no,resizable=no,scrollbars=no,width=1000,he ight=400';
win =
window.open('/nxtt/jsp/main.jsp','_blank','scrollbars=yes,resizable=yes,m enubar=no,toolbar=no,status=no');
thanks for time

regards
Jaggu

May 11 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Jaggu said the following on 5/11/2006 1:42 PM:
Hi ,

I need to close main window, once the child window succesfully opens
else main window to remain.
Then click the X on the corner of the browser.
In my case when I close the main window immediately after the
"window.open()" as mentioned below, both the main and child
disappears(this is due to pop up blocker) disappears suddenly.
I want to make the browser know if pop up blocks the child
window(in case).
Stop trying to close my windows, you don't have that problem.
help me how to check the child window opened successfuly or not, on
successful closing the main window.
Search the archives, it has been explained before.
//main window
function onLoad(){
var feat =
'toolbar=no,directories=no,location=no,status=no,m enubar=no,resizable=no,scrollbars=no,width=1000,he ight=400';


Hmmm, no toolbar, no location bar, you can't kill my statusbar, no
resize. Are you crazy?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 11 '06 #2

P: n/a
Jaggu wrote :
Hi ,

I need to close main window, once the child window succesfully opens
else main window to remain.
IE 7 beta 2 has fixed that issue/possibility: you will never be able to
close a window which has not been opened via javascript. You never
should have been able to do this in the first place.
As a general rule, a script can never close a window which was not
opened via javascript.

In my case when I close the main window immediately after the "window.open()" as mentioned below, both the main
and child disappears(this is due to pop up blocker) disappears
suddenly. I want to make the browser know if pop up blocks the child
window(in case).

help me how to check the child window opened successfuly or not, on
successful closing the main window.
//main window
function onLoad(){
var feat =
'toolbar=no,directories=no,location=no,status=no,m enubar=no,resizable=no,scrollbars=no,width=1000,he ight=400';


Let's get into your perspective versus the users' perspective. The user
has a window which has a toolbar, a location bar, a status bar and a
menubar: all these are fully and completely under the user's control.
And you want a secondary window to open and to have no toolbar, no
location bar, no status bar, no menubar.

Do you think that your plan and design is user-friendly?

Gérard
--
remove blah to email me
May 14 '06 #3

P: n/a

Gérard Talbot wrote:
Jaggu wrote :
Hi ,

I need to close main window, once the child window succesfully opens
else main window to remain.


IE 7 beta 2 has fixed that issue/possibility: you will never be able to
close a window which has not been opened via javascript. You never
should have been able to do this in the first place.
As a general rule, a script can never close a window which was not
opened via javascript.

In my case when I close the main window
immediately after the "window.open()" as mentioned below, both the main
and child disappears(this is due to pop up blocker) disappears
suddenly. I want to make the browser know if pop up blocks the child
window(in case).

help me how to check the child window opened successfuly or not, on
successful closing the main window.
//main window
function onLoad(){
var feat =
'toolbar=no,directories=no,location=no,status=no,m enubar=no,resizable=no,scrollbars=no,width=1000,he ight=400';


Let's get into your perspective versus the users' perspective. The user
has a window which has a toolbar, a location bar, a status bar and a
menubar: all these are fully and completely under the user's control.
And you want a secondary window to open and to have no toolbar, no
location bar, no status bar, no menubar.

Do you think that your plan and design is user-friendly?

Gérard
--
remove blah to email me

Just a little tip if this is the case:
Have any site that links to your page use JavaScript to open up your
page, so that the script closing function will work. That might
override the function built in to IE 7 beta 2, or any other browser
that has that setting.

Submitted for your consideration.

I have the honor to remain your most humble and Ob't Sv't in our war
against the King.

--
Patrick Reilly
1st Coy.
Colonel Seth Warner's Regiment

May 14 '06 #4

P: n/a
use the follwong code to close main window, once the child window
succesfully opens

<script>
//popup window
function onLoad(){
window.parent.opener.close();
}

hope its help you

regards
mick

May 14 '06 #5

P: n/a
pe********************@gmail.com wrote:
<snip>
Just a little tip if this is the case:
Have any site that links to your page use JavaScript to
open up your page, so that the script closing function
will work.
By and large web sites want other people to link to them (that is a
major factor in where a page will show up in, for example, google search
result listings), and the want people to visit them (as they serve no
purpose at all if they are never viewed). Attempting to impose any
restrictions on the people who link to a site is going to discourage
them from linking to it, and insisting that those links are javascript
dependent (and so vulnerable to all pop-up blocking mechanisms) would
act to minimise the number of people able to follow such links
(discouraging visitors). A doubly counter-productive suggestion.
That might override the function built in to IE 7 beta 2,
or any other browser that has that setting.

Submitted for your consideration.

<snip>

It is a hackish suggestion attempting to mitigate the consequences of a
bad initial design decision.

Richard.
May 14 '06 #6

P: n/a
micky b said the following on 5/14/2006 9:36 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
use the follwong code to close main window, once the child window
succesfully opens
And then ask why it doesn't work.
<script>
//popup window
function onLoad(){
window.parent.opener.close();
}
And if that window wasn't opened with script, you will get a dialog (if
you are lucky and using IE) about security issues and some inept web
master attempting to close your window.
hope its help you


It didn't.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 14 '06 #7

P: n/a
micky b wrote:
<script>
The required `type' attribute is missing:

<script type="text/javascript">
//popup window
function onLoad(){
window.parent.opener.close();
}

The close tag is missing:

</script>
hope its help you


That is highly unlikely. For

a) If included as is, the function code is unlikely to be executed.
1. Invalid markup.
2. Wrong identifier. See b)

b) The function could have been called if the identifier was `onload'.
In that case, the identifier would overwrite the `window.onload'
event listener /iff/ properties of the Global Object would act as
properties of the Window object of the global execution context.
In that case, it would be identical to the rather sane

window.onload = function window_onload()
{
...
};

c) In that case, the parent window, unless opened through scripting itself,
will not be closed without showing a cancellation dialog to the user
first, due to security measures. Or the parent window, unless opened by
script itself, will not be closed at all silently, due to other security
measures.

d) If the opener was closed already, a script error is likely, as the
reference window.parent.opener is void then. If it or the popup window
shows a different (esp. deeper nested) frameset than before, either a
script error will occur or simply nothing happens then.
PointedEars
--
The English government is much of a German poodle as
other governments. The Germans infiltrated them all.
-- "The only real Barbara Schwarz", dsw.scientology,
<16**************************@posting.google.com >)
May 22 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.