#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

  • PaulC

    PaulC February 1st, 2010 @ 10:44 AM

    This appears to be in the Prototype Documentation project. I apologise for creating this ticket in the wrong project.

    Can the ticket be moved to the Prototype project please?

  • Rob Staveley (Tom)

    Rob Staveley (Tom) February 8th, 2010 @ 12:23 PM


    I've been bitten by this issue in a project with MovableType, which defines an attachEvent function in a scripts that mantatory for handling sign-in and comments. See http://www.movabletype.org/mt.js (2010-02-08) to view the script.

    My work-around in a project that includes jQuery was to include prototype at the bottom of the page like this:

    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
        if (!jQuery.browser.msie)
            window.attachEvent = null;  // rstaveley: Removing mt.js function with fingers crossed!
        google.load("prototype", "");

    i.e. to depend on jQuery's browser detection, which looks for msie in the UserAgent name and to clobber MovableType's function in the hope that it is no longer needed after the page has been loaded.

  • Dan Dean
  • Tisho Georgiev

    Tisho Georgiev March 1st, 2010 @ 03:04 PM

    • Tag changed from browser detection to needs:discussion, needs:patch
    • State changed from “new” to “enhancement”
  • Tobie Langel

    Tobie Langel March 1st, 2010 @ 06:07 PM

    • Tag changed from needs:discussion, needs:patch to general, needs:discussion, needs:patch
  • aliyahbrown

    aliyahbrown June 15th, 2018 @ 06:19 AM

    I hope you continue to have such quality articles to share with everyone! I believe a lot of people will be surprised to read this article geometry dash

  • vedant

    vedant July 23rd, 2018 @ 08:17 AM

    After all i have no need to find more site or game for my study and enjoy because now i have scrabble word finder this site. Here this site give me more knowledge and joy in the game. So guys i want to say that if you also want then came faster and just try it.

  • panistefanin

    panistefanin October 5th, 2018 @ 09:37 AM

    Je vous remercie de l'information! Je cherchais et ne pouvait pas trouver. Vous me aidé! percentage difference calculator

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