While reviewing some code, I encountered a problem in Internet Explorer 7 and 8. Despite the constructor executing properly when stepped through, upon returning I received an error stating "Object does not support this property or method." How frustrating!
An important detail to note is that the variable embedDialog is globally scoped (even though globals are generally frowned upon, I did not create this code).
// Causes error in IE8 and IE7 - "Object does not support this property or method"
embedDialog = new Dialog({
id: "embedDialog",
width: 400,
height: 400,
message: "Check it out",
title: 'Cool dialog box'
});
By giving embedDialog functional scope, the issue is resolved:
// Remove global scope and it works
var embedDialog = new Dialog({
id: "embedDialog",
width: 400,
height: 400,
message: "Check it out",
title: 'Cool dialog box'
});
Alternatively, changing the value of the id property to something other than the variable name also fixes the problem:
// Change "embedDialog" to "embedDialogBox" and it works
embedDialog = new Dialog({
id: "embedDialogBox",
width: 400,
height: 400,
message: "Check it out",
title: 'Cool dialog box'
});
What could be causing this issue with IE? Can anyone shed light on why the original code triggers problems in IE 7/8?