OZONE Asylum
Forums
DHTML/Javascript
20 Liners - January 08 - Dynamics
This page's ID:
29836
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
[b]MaGnA:[/b] Nice optimizations. I see you're using the JS 1.6+* Array.prototype.every method which is a Mozilla invention. To make your code cross browser, you can add this 2 liner[code]Array.prototype.every = Array.prototype.every||function( callback, that ) { for( var i=0; i<this.length && callback.call( that||this, this[i] ); i++ ); return i==this.length; }[/code]This at least makes the script work in Opera 9.5, but thows in IE7. Will try to figure why. Regarding mouse capturing, for line optimized things, you can do it in 2 lines.[code]element.onmousemove = function( event ) { var event = window.event||event; window.mouse = { x:event.offsetX||event.pageX, y:event.offsetY||event.pageY, b:event.which||event.button?true:false } }[/code]Where [i]element[/i] is an overlayed element on top of the area you want to capture the mouse. HTH As for my saying about using an array instead of classNames, I don't know for sure. It's more a gut feeling. OTO the functions hash table technique is really compact. *: wouldn't be great if there was a standard body for JavaScript instead of browser vendords adding whatever they want with no discussion. :o I'm really looking forward to ES4 [url=http://www.p01.org/][img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_love_small.gif[/img][/url] [small](Edited by [url=http://www.ozoneasylum.com/user/2185]poi[/url] on 01-29-2008 20:39)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »