« Cross Site Scripting via RSS? Foreign Press Calling for President’s Assasination »
Another IE JavaScript Difference - TypeOf Operator
Posted October 22, 2004 – 11:42 am by Yakov Shafranovich in ProgrammingAnother rather annoying thing I just ran across is the difference in the implementation of the “typeof” operator in Javascript operating on functions. If you create a function in the parent window, assign it to a property of the parent window, and then pass it to the child window, IE will display the “typeof” of that property as “object” while other browsers will display it as “function”. I know it is an obsure scenario, but nevertheless a rather strange one. I used the following code to create the function and assign the property of the window:
function test_func() { }
window.test = test_func;
If you execute the following snippet in the same window as the function, all browsers will display “function” :
alert(typeof window.test);
BUT if you try to do the same thing in any of the children forms, the results will vary between IE and other browsers. In IE, the result will be “object” even though the code above returns “function”. All other browsers will return “function”. I used the following snippet:
alert(typeof window.opener.test);
And here you can test it yourself - on most browsers the buttons below will return the same results, but on IE they will be different (doesn’t work via RSS):
Tags: firefox, ie, javascript —
Permalink | Trackback URL | This post has















Sorry, comments for this entry are closed at this time.