NYCPHP Meetup

NYPHP.org

[nycphp-talk] OT: Javascript - Opening a new window, but the window name is getting lost with Facebook.com

David Roth davidalanroth at gmail.com
Wed Sep 29 01:56:45 EDT 2010


I was successfully using Javascript code for years to open a new  
browser window and assign it a unique name without any problems. That  
is, until now. :-)

The following Javascript code works properly with any other website  
I've tried, except for facebook.com:

<a href="javascript: void(0)"
    onclick="window.open('http://facebook.com/USERNAME_GOES_HERE',
   'windowname1',
   'width=600, \
    height=500, \
    directories=no, \
    location=no, \
    menubar=no, \
    resizable=no, \
    scrollbars=1, \
    status=no, \
    toolbar=no');
   return false;">Become a friend on Facebook:</A>
The above action, will open a window, but if the visitor to the web  
page clicks on that same link again, it opens yet another new window.  
It shouldn't do that, because 'windowname1' should simply cause the  
user to bring that window up front, not create a duplicate window each  
time the link is clicked.

I have tried variations of the above code, but they all fail as I  
described when it comes to facebook.com, but works well on many other  
websites I tried.

I'm not a web browser guru, so I can only guess at how the internals  
of it work for assigned 'windowname1'. But here is my theory and I'd  
greatly appreciate comments on this. I suspect that when facebook.com  
is loaded it immediately renamed the assigned window to some unique  
window name perhaps with embedded UNIX time stamp to make it extremely  
unique. If my theory is correct, is there any way to have your own  
window name be used instead? Or is there some other Javascript coding  
method to accomplish this with Facebook.com that someone is just  
itching to tell me about?  If my theory is wrong about facebook.com,  
can someone explain why they might be doing this and what advantage is  
there to Facebook.com being more difficult than the other websites? :-)

Thanks in advance,

David Roth

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20100929/f8dd2b82/attachment.html>


More information about the talk mailing list