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 04:45:22 EDT 2010


Thanks for your reply, John.

Your code example didn't solve the problem it just opened duplicate  
tabs each time the link was clicked in Google Chrome & Firefox.  
Testing it with Safari on the Mac it didn't open a new tab, but a new  
window just as the code example I provided did.

There were reasons why it was done that way which aren't relevant to  
the initial problem and questions relating to my posting. As for your  
harsh criticisms, I suspect you are simply having a bad day and hope  
it gets better for you soon.

David Roth

On Sep 29, 2010, at 2:59 AM, John Campbell wrote:

> I don't know why this isn't working, but using window.open is a
> terrible practice.
>
> What is wrong with:
>
> <a href="http://face..." target="friend">Become a friend on  
> Facebook:</a>
>
> If you do it that way it loads in a new tab, which is much faster than
> creating a new window, and doesn't irritate the user.  Why would you
> want to create a window that is not resizable and without a location
> bar?  That is just plain rude.  Thank god all decent browsers ignore
> it.
>
> -John Campbell
>
> On Wed, Sep 29, 2010 at 1:56 PM, David Roth  
> <davidalanroth at gmail.com> wrote:
>> 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
>>
>> _______________________________________________
>> New York PHP Users Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/Show-Participation
>>
> _______________________________________________
> New York PHP Users Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/Show-Participation




More information about the talk mailing list