PDA

View Full Version : jQuery - set var whilst loading, call on load IE problem


Adam_C
02-28-2011, 10:54 PM
Hi,

When my page is loading it uses the Facebook Javascript API to determine whether or not a user is signed in to Facebook, if they are signed in
window._signedInToFacebook = true;
... otherwise ...
window._signedInToFacebook = false;

Then one the page has loaded I want to - for testing purposes - show the value of the _signedInToFacebook in an alert message, however, when I run the jQuery code

if ($.browser.msie) {
$(document).ready(function(){
alert(window._signedInToFacebook);
});
} else {
$(window).load(function(){
alert(window._signedInToFacebook);
});
}

in Chrome everything works perfectly, but - no surprise - IE just throws an 'undefined' message at me.

Even if I try:
<body onLoad="alert(window._signedInToFacebook);">
I still get no luck, I've done some routing around but can't find anything like this I guess because its quite specific criteria...

Does anyone know how to correct this?

By the way I'm using newest Chrome release and IE9 beta...

Thanks in advance :D