From ef0c84072bc2101a5d056430729528cbc5ed8a8f Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Mon, 11 Jan 2010 22:33:08 -0800 Subject: [PATCH] Fix the platform identifying code. Fix the longstanding IE refresh bug by ensuring document is ready. Closes #98. --- Objective-J/Runtime/bootstrap.js | 26 +++++++++++++++++++++++++- Objective-J/Runtime/file.js | 11 +++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Objective-J/Runtime/bootstrap.js b/Objective-J/Runtime/bootstrap.js index 42d4767e6..b39ddfde2 100644 --- a/Objective-J/Runtime/bootstrap.js +++ b/Objective-J/Runtime/bootstrap.js @@ -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); + }); +} diff --git a/Objective-J/Runtime/file.js b/Objective-J/Runtime/file.js index 50f356451..6be59a575 100644 --- a/Objective-J/Runtime/file.js +++ b/Objective-J/Runtime/file.js @@ -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