Opened 15 years ago

Closed 15 years ago

#3528 closed defect (fixed)

If IE7's user-agent string gets too long, addOnLoad fails.

Reported by: guest Owned by: anonymous
Priority: high Milestone: 0.9beta
Component: General Version: 0.4.2
Keywords: Cc:
Blocked By: Blocking:


This is a very odd one, but we encountered it in testing our site. If you add extra identifiers to IE7's user agent string that add up to more than 260 or so characters, IE7 has a bug that makes it report that it is IE6. This in turn makes functions passed into addOnLoad not get called.

To repro:

1) Go into your registry using Regedit.exe.

2) Navigate to HKLMSoftwareMicrosoftWindowsCurrentVersionInternet Settings5.0User AgentPost? Platform

3) Create a *new* string key with a very long *name* (the value can be blank). I've used "long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key" as my key.

4) Close all instances of IE.

5) Fire up IE and point it at a page that uses dojo.addOnLoad. It will not call any of the onLoad functions you send to it.

IE7 adds all of the names of keys in Post Platform to the end of the User Agent string. However, when those strings add up to more than 260 characters or so, the call to navigator.userAgent has a bug and always returns "Mozilla/4.0 (compatible; MSIE 6.0)". Since it doesn't say "Windows" in the UA string, dojo sets to false.

Now, when it comes to adding the onload event, dojo has the following test for the IE branch:

if( &&{

document.attachEvent("onreadystatechange", function(e){

if(document.readyState == "complete"){





Since, is false, it doesn't hit this branch, and dj_load_init is never called.

I know this is a bit of a far-fetched corner case, but if someone has a bunch of .NET CLRs, spyware, or toolbars installed, their User Agent string can get quite long. And when it happens, it's pretty difficult to debug.

Interestingly, the UA string sent to servers does not have this bug; it's only in the UA string from navigator.userAgent.

Change History (2)

comment:1 Changed 15 years ago by guest

Sorry, I misspoke about the threshhold for the IE7 UA bug. As far as I can tell, it happens when the whole UA string is 260 or more characters, not just the Post Platform piece. In any case, the instructions I gave should give you a repro case.

comment:2 Changed 15 years ago by James Burke

Milestone: 0.9beta
Resolution: fixed
Status: newclosed

This is fixed in 0.9, since that part of the code only tests for IE, and does not check for the OS platform.

Note: See TracTickets for help on using tickets.