So I have a window property variable that I need to delete, and of course IE hates the delete
method. I've tried the solution found here, like so:
try {
delete window.locator_init_in_progress;
}
catch (e) {
window.locator_init_in_progress = undefined;
}
Now I get the following error in IE8:
What do I need to do to make this stop throwing errors and work in IE8? (I'm assuming it's the try
part that's throwing the error, but this code will not pass our QA process if there are any errors in the console, so what do I need to do so this works? Should I just abandon the try/catch and do a test for user-agent, and if it's IE8, set the property to undefined?
UPDATE
Yes, the variable is defined. I've added some alerts in, since IE8 can blow up on console.logs. Here's my current code:
// window.ie8orearlier is a global variable that is set
// based on user agent string; in this case it's correctly
// evaluating to true when testing in IE8
if(window.ie8orearlier && window.locator_init_in_progress!= undefined && window.locator_init_in_progress == true) {
alert("ie8 and value is set; not undefined");
window.locator_init_in_progress = undefined;
}
else if(window.ie8orearlier && window.locator_init_in_progress == undefined) {
alert("ie8 and undefined; do nothing");
}
else {
alert("else");
delete window.locator_init_in_progress;
}
It's consistently hitting the "ie8 and value is set; not undefined" alert. The error, as far as I can see (IE8's dev tools not providing line numbers for errors), is being thrown by the line trying to set the value to undefined.