Tuesday, February 19th, 2008
I ran across a few posts in a row in my news reader that were each mini tips that involved Prototype, Firefox, and IE.
Prototype Custom Events
Howard Lewis Ship is making sure that Tapestry 5 will have 50% more Ajax, and has been playing with Prototype. He found a nagging bug to do with a ‘:’:
Here’s an important note: custom events, used with the fire() function must contain a colon.
this.form.fire("prepareforsubmit")will do nothing.
this.form.fire("form:prepareforsubmit")will properly invoke observers. This is not yet documented, though the ironically named blog Painfully Obvious clued me in.
Firefox 3 Array Insanity
Alex spent some time that I bet he wishes he could get back as he proved that he wasn’t insane as he ran this in Firefox 3:
- >>> typeof 
- >>> var a = ;
- >>> var b = new Array();
- >>> a.constructor == b.constructor
- >>> c = ;
- >>> c.constructor == a.constructor
- >>> d = new Array();
- >>> b.constructor == d.constructor;
- >>> b.constructor == a.constructor;
Dushan Hanuska of Atlassian has posted about getting IE to remember its own position:
We try to build user friendly applications as much as we can. As a convenience this little pop-up has a remember-my-position feature. Position (and size) of the window is stored in a browser cookie. This feature works fine on most browsers, however Internet Explorer has some quirks. To be more specific, IE pushes this window off its original position each time this window is opened.
It seems that the offset happens when the window is moved to x,y (
window.moveTo(x,y)) and then asked for its x and y (
window.screenTop). Hence the following code will move the window diagonally down and to the right ten times.
for (var i=0;i<10;i++) window.moveTo(window.screenLeft,window.screenTop);
Did I mention that IE is broken? No? IE is broken. You don’t believe?! Figure this! When you call
window.moveTo(x,y)the window dutifully follows your command and moves the upper left corner of the window to x and y on the screen. But when you ask it for its position it will try to fool you by giving you incorrect co-ordinates. And it will succeed. The
window.screenTopis the only way to get the position of a window on Internet Explorer.
The reason for this offset comes from the difference in position of the browser window (outer window) and the document window (inner window).
The solution? Don’t use pop-up windows. Problem solved.
Posted by Dion Almaer at 7:02 am