Skip to content

Commit

Permalink
Fix the platform identifying code.
Browse files Browse the repository at this point in the history
Fix the longstanding IE refresh bug by ensuring document is ready.
Closes cappuccino#98.
  • Loading branch information
Ross Boucher committed Jan 12, 2010
1 parent 608853d commit ef0c840
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
26 changes: 25 additions & 1 deletion Objective-J/Runtime/bootstrap.js
Expand Up @@ -21,4 +21,28 @@
*/

if (window.OBJJ_MAIN_FILE)
objj_import(OBJJ_MAIN_FILE, YES, function() { main(); });
{
var addOnload = function(handler
{
if (window.addEventListener)
window.addEventListener("load", handler, false);
else if (window.attachEvent)
window.attachEvent("onload", handler);
}

var documentLoaded = NO;
var defaultHandler = function()
{
documentLoaded = YES;
}

addOnload(defaultHandler);

objj_import(OBJJ_MAIN_FILE, YES, function()
{
if (documentLoaded)
main();
else
addOnload(main);
});
}
11 changes: 7 additions & 4 deletions Objective-J/Runtime/file.js
Expand Up @@ -32,10 +32,13 @@ var OBJJ_ENVIRONMENTS = ENVIRONMENTS;
#ifdef PLATFORM_USERAGENT
var userAgent = window.navigator.userAgent;

if (userAgent.indexOf("MSIE 7") !== -1)
OBJJ_ENVIRONMENTS.unshift("IE7");
else if (userAgent.indexOf("MSIE 8") !== -1)
OBJJ_ENVIRONMENTS.unshift("IE8");
if (userAgent.indexOf("MSIE") !== -1)
{
if (userAgent.indexOf("MSIE 8") !== -1)
OBJJ_ENVIRONMENTS.unshift("IE8");
else
OBJJ_ENVIRONMENTS.unshift("IE7");
}
else
OBJJ_ENVIRONMENTS.unshift("W3C");
#endif
Expand Down

0 comments on commit ef0c840

Please sign in to comment.