I have a window, where before being closed I refresh the underlying page.
if(opener && typeof(opener.Refresh) != 'undefined')
{
opener.Refresh();
}
If I moved away from the original opening page, this code would throw a “Permission Denied” error.
Debugging the code revealed that typeof(opener.Refresh) was equal to “unknown” instead of the expected “undefined”.
As far as I’m aware “unknown” is not one of the return values for typeof, so how and why would this value be returned?
Further Information
I avoided the error by changing the check to:
if(opener && typeof(opener.Refresh) == 'function')
However examples like this (detecting-an-undefined-object-property-in-javascript) do not seem to factor “unknown” into the equation.
According to a duplicate question at Bytes, the typeof value
unknownis added to JScript version 8, along withdate.A comment to a blog by Robert Nyman can also be explanatory: