On Thu, Jul 3, 2008 at 8:17 AM, Sam Sherlock <[EMAIL PROTECTED]> wrote:
> this is some I am thinking about and an approach that I may take, have'nt
> got to that stage yet but window.closed looks good
>
> http://bytes.com/forum/thread91209.html
>
> 2008/7/3 Bruce MacKay <[EMAIL PROTECTED]>:
>>
>> More searching has led me to a solution, and another question
>>
>>         $("a.openW").click(
>>          function(e) {
>>             var sTarget = this.href;
>>             if (winRef && ! winRef.closed){
>>                  winRef.focus();
>>              }else {
>
>                  winRef=window.open(sTarget);
>             }
>              // or do I mean stopProgation
>              e.preventDefault();
>          });
>
> This code does the necessary check, but it won't move focus to the existing
> opened window (that contains the help file).
>
> What am I not doing correctly?
>
> Thanks,
>
> Bruce
>
>
>
> At 01:11 p.m. 3/07/2008, you wrote:
>
> Hello folks,
>
> I can't find the answer I need in the archives (Nabble), so my question is
> how do I check to see if a window exists before I open it?
>
> When a user of my application clicks on a help link, I want the help file to
> load into a new window.  I'm doing that via...
>
>         $("a.openW").click(
>          function() {
>              window.open(this.href); return false;
>          });
>
> But I want to first make sure that a window containing the help file isn't
> already open before a new one (another one) is opened.
>
> Help/direction appreciated.
>
> Thanks,
>
> Bruce
>





According to this code, i think you should simply reference the
variable holding the window.open result in a wider scope, and you
won't have to check: it will use the same window name property:

var winRef = null;

    $("a.openW").click(
             function(e) {
                var sTarget = this.href;
                winRef=window.open(sTarget);
             // or do I mean stopProgation
             e.preventDefault();
         });

Reply via email to