Re: How to check for a named window



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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
.


Quantcast