Search this site


Metadata

Articles

Projects

Presentations

javascript: the 'top' object.

My jquery puffer demo wasn't working in IE. This was the error:

Line 25 is:

  top = pos[1];

Turns out 'top' is one of those magically populated objects. In Firefox, you are allowed to assign to top and hence the demo works. In IE, it tells you that assignment is not implemented for that particular object.

In IE, alerting 'top' will show '[object]'. In Firefox, alerting 'top' will show '[object Window]'

If I change my code to use 'top_pos' instead of 'top', the demo works now.


2 responses to 'javascript: the 'top' object.'

Showing last 2 comments... (Click here to view all comments)

Ryan wrote at Fri Aug 17 11:41:35 2007...
Are you sure you don't have an element in your HTML with id="top"? IE automagically creates JS objects with the same name as element ids. I ran into similar problems a few times.

Jordan Sissel wrote at Fri Aug 17 19:27:49 2007...
Interesting, didn't know that. However, that doesn't seem to be the case here. Doing 'javascript:alert(top)' in the urlbar on a blank page in Firefox says it's a Window object. I suspect you'd get similar output as mentioned above in IE.


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional, if you want me to be able to email you back)
URL (also optional)
Comment: