How to check for a named window

T

Todd

A window may or may not be created by me and JavaScript. When the "OK"
button is pressed, I do a JavaScript Close(), but I want to make that
conditional on whether the user is in a window called "pdfWin".

Currently the button is created with

<input name="btnContinue" type="button" onClick="MM_closeWindow()"
value="OK">

And my MM_closeWindow() is

function MM_closeWindow() {
window.close();
}

Not that is really matters, all of this is in my PHP code.

Thank you......

Todd
 
I

Ivo

A window may or may not be created by me and JavaScript. When the "OK"
button is pressed, I do a JavaScript Close(), but I want to make that
conditional on whether the user is in a window called "pdfWin".

function MM_closeWindow() {
window.close();
}

Make that:
if( window.name==='pdfWin' ) { window.close(); }
Not that is really matters, all of this is in my PHP code.

Speaking of what matters, it may be in a page which is in whole or part
produced by a PHP script, but the underlying origin is of no concern once
downloaded. The code you showed is nothing but the purest HTML and
Javascript.
hth
ivo
http://4umi.com/web/javascript/
 
R

Randy Webb

Todd said the following on 10/30/2005 2:13 PM:
A window may or may not be created by me and JavaScript. When the "OK"
button is pressed, I do a JavaScript Close(), but I want to make that
conditional on whether the user is in a window called "pdfWin".

If you only want the button available in the window named pdfWin, then
only generate the code for that window.
Currently the button is created with

<input name="btnContinue" type="button" onClick="MM_closeWindow()"
value="OK">

And my MM_closeWindow() is

function MM_closeWindow() {
window.close();
}

That looks like left over Dreamweaver code. If nothing else, change the
name so that nobody else is aware that you have ever used DW created
scripts. It also seems counter-productive to call a function that only
closes a window.
Not that is really matters, all of this is in my PHP code.

Add a parameter to the URL that lets the server know you are opening it
in pdfWin and only generate the code for that page if it is in pdfWin.

Barring that, you can check the windows name property.

if (window.name == 'pdfWin'){
window.close();
}

You may look into generating that button so that if the page is not in
pdfWin, then users don't get a broken button.

But, why do people seem to want to duplicate browser functionality?
Most, if not all, browsers have an X in the corner to close it, and most
users know how to close that window without a button/link on a page to
do it for them.
 
T

Todd

Randy -

<<<
But, why do people seem to want to duplicate browser functionality?
Most, if not all, browsers have an X in the corner to close it, and most
users know how to close that window without a button/link on a page to
do it for them.Apparently you have not had the experience of working for
attorney clients like mine...you lucky!!

<<<
Add a parameter to the URL that lets the server know you are opening it
in pdfWin and only generate the code for that page if it is in pdfWin.Great solution!! Thank you. If you put this into your browser, you got
there without a valid session_id; therefore, the window was not created:

http://209.204.172.137/carf/php/show_image.php

<<<
If nothing else, change the name so that nobody else is aware that you
have ever used DW created scripts.And due to my lack of JavaScript experience, I thought that was a
routine naming convention :) . Though I have DreamWeaver, I found that
the code it produces was more confusing than even my HTML. I was asked
to add some PHP code to a non-profit Web site and when I told the "Web
master" that all he would have to do is add some HTML code to his pages,
he told me that he does not know HTML; he uses DreamWeaver. Uggggg!

Thank you for the suggestions...greatly appreciated! Love to
communicate with you off line.

Todd
 
R

Randy Webb

Todd said the following on 10/30/2005 4:38 PM:
Randy -

<<<
But, why do people seem to want to duplicate browser functionality?
Most, if not all, browsers have an X in the corner to close it, and most
users know how to close that window without a button/link on a page to
do it for them.

Apparently you have not had the experience of working for
attorney clients like mine...you lucky!!

No but some just as dumb. I usually remind them that they are
professionals in there profession, not mine. And I usually end up
knowing better about mine than they do.
<<<
Add a parameter to the URL that lets the server know you are opening it
in pdfWin and only generate the code for that page if it is in pdfWin.

Great solution!! Thank you. If you put this into your browser, you got
there without a valid session_id; therefore, the window was not created:

http://209.204.172.137/carf/php/show_image.php

Then you shouldn't have the problem you describe. If php only generates
the page when you allow it, and you generate the link via JS, then only
JS can open that window.
<<<
If nothing else, change the name so that nobody else is aware that you
have ever used DW created scripts.

And due to my lack of JavaScript experience, I thought that was a
routine naming convention :) . Though I have DreamWeaver, I found that
the code it produces was more confusing than even my HTML. I was asked
to add some PHP code to a non-profit Web site and when I told the "Web
master" that all he would have to do is add some HTML code to his pages,
he told me that he does not know HTML; he uses DreamWeaver. Uggggg!

I have had similar experiences. Whenever I need a good laugh, I remember
them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top