Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » JavaScript

Closing a window

 
Jump to:  
 
Todd Cary
PostPosted: Fri Sep 05, 2008 3:17 am    Post subject: Closing a window
       
I create a new window with

onClick="openBrWindow(\'claimant_pdf.php\',\'\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

as part of a submit button.

Now I would like to close the window in my php code if a line is
executed e.g. an echo statement. What syntax do I use to execute
window.close()?

Many thanks...

Todd
 

 
GArlington
PostPosted: Fri Sep 05, 2008 10:54 am    Post subject: Re: Closing a window
       
On Sep 5, 6:17 am, Todd Cary <t...@aristesoftware.com> wrote:
Quote:
I create a new window with

onClick="openBrWindow(\'claimant_pdf.php\',\'\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

as part of a submit button.

Now I would like to close the window in my php code if a line is
executed e.g. an echo statement.  What syntax do I use to execute
  window.close()?

Many thanks...

Todd

You can NOT close the window in your PHP code because... Please think
about it yourself...
You can close the window in Javascript if you know window's name - the
second parameter in your window.open code that is currently empty -
give it some name (preferably unique, but repeatable - so do NOT use
UUID) and use that name to address and close the window...
 

 
Nick S
PostPosted: Fri Sep 05, 2008 2:02 pm    Post subject: Re: Closing a window
       
On Sep 5, 7:17 am, Todd Cary <t...@aristesoftware.com> wrote:
Quote:
I create a new window with

onClick="openBrWindow(\'claimant_pdf.php\',\'\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

as part of a submit button.

Now I would like to close the window in my php code if a line is
executed e.g. an echo statement. What syntax do I use to execute
window.close()?

Many thanks...

Todd

While Garlington is correct in a very literal sense, if you echo out
window.close(theWindow) you will be able to close the window if you
open it with

onClick="var theWindow = openBrWindow(\'claimant_pdf.php\',\'\',
\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

(I think) Smile I've not tested it as I'm not at my PC Smile
 

 
Nick S
PostPosted: Fri Sep 05, 2008 2:04 pm    Post subject: Re: Closing a window
       
On Sep 5, 4:02 pm, Nick S <nrsut...@gmail.com> wrote:
Quote:
On Sep 5, 7:17 am, Todd Cary <t...@aristesoftware.com> wrote:

I create a new window with

onClick="openBrWindow(\'claimant_pdf.php\',\'\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

as part of a submit button.

Now I would like to close the window in my php code if a line is
executed e.g. an echo statement. What syntax do I use to execute
window.close()?

Many thanks...

Todd

While Garlington is correct in a very literal sense, if you echo out
window.close(theWindow) you will be able to close the window if you
open it with

onClick="var theWindow = openBrWindow(\'claimant_pdf.php\',\'\',
\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

(I think) Smile I've not tested it as I'm not at my PC Smile

ooh wait a minute, if you're echoing out from PHP you'll be refreshing
the page and therefore losing the window handle "theWindow", I would
suggest using ajax to accomplish what you want to do in php that way
you maintain state on the page and can close the window
 

 
Todd Cary
PostPosted: Fri Sep 05, 2008 4:43 pm    Post subject: Re: Closing a window
       
GArlington wrote:
Quote:
On Sep 5, 6:17 am, Todd Cary <t...@aristesoftware.com> wrote:
I create a new window with

onClick="openBrWindow(\'claimant_pdf.php\',\'\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

as part of a submit button.

Now I would like to close the window in my php code if a line is
executed e.g. an echo statement. What syntax do I use to execute
window.close()?

Many thanks...

Todd

You can NOT close the window in your PHP code because... Please think
about it yourself...
You can close the window in Javascript if you know window's name - the
second parameter in your window.open code that is currently empty -
give it some name (preferably unique, but repeatable - so do NOT use
UUID) and use that name to address and close the window...

Point well taken. So if I had

onClick="openBrWindow(\'claimant_pdf.php\',\'PrintWin\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

what would the syntax be to PrintWin.close()? What would I echo
to execute the JavaScript?

Many thanks
Todd
 

 
Todd Cary
PostPosted: Fri Sep 05, 2008 9:32 pm    Post subject: Re: Closing a window
       
Nick S wrote:
Quote:
On Sep 5, 8:43 pm, Todd Cary <t...@aristesoftware.com> wrote:
GArlington wrote:
On Sep 5, 6:17 am, Todd Cary <t...@aristesoftware.com> wrote:
I create a new window with
onClick="openBrWindow(\'claimant_pdf.php\',\'\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"
as part of a submit button.
Now I would like to close the window in my php code if a line is
executed e.g. an echo statement. What syntax do I use to execute
window.close()?
Many thanks...
Todd
You can NOT close the window in your PHP code because... Please think
about it yourself...
You can close the window in Javascript if you know window's name - the
second parameter in your window.open code that is currently empty -
give it some name (preferably unique, but repeatable - so do NOT use
UUID) and use that name to address and close the window...
Point well taken. So if I had

onClick="openBrWindow(\'claimant_pdf.php\',\'PrintWin\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

what would the syntax be to PrintWin.close()? What would I echo
to execute the JavaScript?

Many thanks
Todd

Is the code that closes the window going to be in the opened window or
the calling window?

It will be in the Opened Window. If an error is created, the
code takes the user to the error window, so now it is leaving
behind an opened window.

Usually the user closes the window....

Todd
 

 
Nick S
PostPosted: Fri Sep 05, 2008 11:01 pm    Post subject: Re: Closing a window
       
On Sep 5, 8:43 pm, Todd Cary <t...@aristesoftware.com> wrote:
Quote:
GArlington wrote:
On Sep 5, 6:17 am, Todd Cary <t...@aristesoftware.com> wrote:
I create a new window with

onClick="openBrWindow(\'claimant_pdf.php\',\'\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

as part of a submit button.

Now I would like to close the window in my php code if a line is
executed e.g. an echo statement. What syntax do I use to execute
window.close()?

Many thanks...

Todd

You can NOT close the window in your PHP code because... Please think
about it yourself...
You can close the window in Javascript if you know window's name - the
second parameter in your window.open code that is currently empty -
give it some name (preferably unique, but repeatable - so do NOT use
UUID) and use that name to address and close the window...

Point well taken. So if I had

onClick="openBrWindow(\'claimant_pdf.php\',\'PrintWin\',\'toolbar=no,status=yes,scrollbars=no,resizable=no\')"

what would the syntax be to PrintWin.close()? What would I echo
to execute the JavaScript?

Many thanks
Todd

Is the code that closes the window going to be in the opened window or
the calling window?
 

 
SAM
PostPosted: Sat Sep 06, 2008 8:57 am    Post subject: Re: Closing a window
       
Todd Cary a écrit :
Quote:
Nick S wrote:

Is the code that closes the window going to be in the opened window or
the calling window?

It will be in the Opened Window.

So, no difficulty :

<?php
if(error) {
echo "<script type='text/javascript'>self.close();</script>";
}
?>

No importance if a new page has been opened in the same popup,
this popup yet knows it has been opened by Javascript and will accept to
be closed by JS

Quote:
If an error is created, the code takes the user to the error window,

You mean your popup open a new one more ?

If it is to close the precedent popup why not to open the error's page
in same popup ?

Quote:
so now it is leaving behind an opened window.

in the daughter of the daughter, to close hers mother :

window.onload = function() {
var ancestor = opener.opener;
opener.close();
opener = ancestor; // the grand mother
};

Quote:
Usually the user closes the window....

setTimeout('self.close()', 2000);

<body onblur="self.close();">
(probably not well working with IE)

--
sm
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

tlumacz z polskiego na angielski sklep internetowy sylwester Kraków Diety Forum Polaków w Wielkiej Brytanii