#997 enhancement

Browser Detection enhancement

Reported by PaulC | January 28th, 2010 @ 10:06 PM

This website describes the issue perfectly. I've just had this issue with a different 3rd party script to the Facebook one listed on the site.


Prototype identifies the browser as IE according to the presence of the IE specific function 'attachEvent'. In prototype.js line 13:

IE: !!(window.attachEvent && !window.opera),
Obviously, this condition is fragile, and will fail if any other included script defines a "window.attachEvent" function for any other browser, which is the exact case of Facebook JS client library.
The Facebook library contains thefollowing line (FacebookApi.debug.js line 387):
if (window.navigator.userAgent.indexOf('Safari') >= 0) {
else {
This code is embedded in an if-condition that it is only executed if the browser is not IE.
The function "_loadMozillaCompat" defines "window.attachEvent" for mozilla browser type, which causes Prototype's IE identification condition to fail, leading to a total mess up in many cases.

The solution is to power up Prototype's IE identification condition, by adding a check that the browser is not mozilla. The new condition looks like that ( and it works :) )

IE: !!(window.attachEvent && !window.opera && navigator.userAgent.indexOf('Gecko') == -1),

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins