Board index » javascript » Newbie... Simple Window close() question

Newbie... Simple Window close() question

2005-01-09 09:56:28 AM
Just thinking off the top of my head, why don't you call a function in
your parent window that does those three things.
window.opener.doAllThree(self)
and then in your parent
function doAllThree(objWindow) {
objWindow.close();
self.focus();
document.location.href = 'whatever.htm';
}
This is definitely just thinking. I'm not even sure that you can pass
the reference to the window object like that or not....hopefully it
will get you closer though.
Micky
-
 

Re:Newbie... Simple Window close() question

"DixieGal" <hhd@ospammers-honeyhousedesigns.com>wrote in message
Quote
I know enough javascript to be dangerous <wink>
I created a link that opens a small popup window.

Now I want my "close window" button to
close the popup, return to the parent window
that opened the popup, and then go to another page.

I can do the close window....
but I am stuck on the return to parent and go to new page...

Any suggestions?
DixieGal

This script uses window.focus, which ensures that the popup will be "on top"
rather than behind the scenes.
You can try adding your window.close() to it and see if this works for you
or not.
It was designed to bring the popup to the front if the visitor did not close
the window and went back to the originating page.
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname,
'width=600,height=100,left=100,top=200,resizable=yes,scrollbars=yes');
return false;
}
//-->
</SCRIPT>
<A
HREF="popupbasic.html"
onClick="return popup(this, 'notes')">my popup</A>
-

Re:Newbie... Simple Window close() question

Richard wrote:
Quote
DixieGal wrote:
<snip>
Quote
Now I want my "close window" button to
close the popup, return to the parent window
that opened the popup, and then go to another page.
<snip>
Quote
This script uses window.focus,
No it doesn't.
Quote
which ensures that the popup will be
"on top" rather than behind the scenes.
Where implemented, in the absence of pop-up blocking, and not disabled
by user settings, - window.focus - would do that, but the method does
not do anything if it is never called.
Quote
You can try adding your window.close() to it and
see if this works for you or not.
There would be little point in doing that as the effect would not
resemble the desired outcome in any way.
Quote
It was designed to bring the popup to the front
if the visitor did not close the window and went
back to the originating page.
If this script was designed with that intention its implementation was
undertaken by a lunatic as the code posted has no relationship to that
proposed design intention.
Quote
<SCRIPT TYPE="text/javascript">
<!--
'Hiding' scripts form 'older browsers' with 'HTML comments' is
redundant.
Quote
function popup(mylink, windowname)
{
if (! window.focus)return true;
Testing the implementation to determine whether it supports the
window.focus method does not make sense unless the code guarded by the
test actually employs that method. Otherwise the implication is that
this is a test by which the environment's support for other features is
being inferred from the existence of an unrelated method. Testing of
that type is utterly unreliable.
Additionally, source code posted to Usenet should always be formally
indented (as described in the FAQ).
Quote
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
Generally, while it might seem that allowing functions to accept
arguments of indeterminate type would result in code that was more
general in its employment, in reality the result is to promote a
disregard for variable type that is dangerous in a loosely typed
language.
The HTML employing this function will only ever pass an object reference
to this function so this branching is not needed, and neither is the
local variable - href -.
Quote
window.open(href, windowname,
Calling a method of the window object that is known not to be
implemented in all environments is obviously misguided. The preceding
test on the wiindow.focus method logically should have been a test on
the widnow.open method, as that is the environment feature that is
actually used by the code.
Quote
'width=600,height=100,left=100,top=200,resizable=yes,scrollbars=yes');
It is almost never a good idea to actively position a newly opened
window as the location in which that window opened may have no
relationship to the existing browser window.
Quote
return false;
Returning false at this point will cancel the navigation specified in
the HREF of the A element. However, at this point it has not been
determined whether the window opening attempt has been successful. in
the event that the window opening attempt failed (or that the new window
will subsequently be closed by an external pop-up blocker) then this
code should return true so that the browser can fall-back to the HTML
link.
Quote
}
//-->
</SCRIPT>

<A
HREF="popupbasic.html"
onClick="return popup(this, 'notes')">my popup</A>
On the whole, inadequate code that bares no apparent relationship to the
OP's question. If you have nothing better to offer you probably should
keep it to yourself.
Richard.
-