eobet
asked on
Creating currentStyle in Mozilla?
Hello!
I've seen usage in code on Google searches of something called __defineGetter__ and __defineSetter__, but I have never gotten this to work (HTMLElement.prototype.__d efineGette r__("funct ionName" function... etc. etc.)
However, I did get a response from HTMLElement.prototype.curr entStyle = function() { return document.defaultView.getCo mputedStyl e(this, ''); }; but Mozilla only said that my element didn't have any properties when I tried it.
Calling the function explicitly (ie. document.defaultView.getCo mputedStyl e(somethin g.somethin g.somethin g, '').something) DOES however work.
What am I doing wrong in my prototype function?
I've seen usage in code on Google searches of something called __defineGetter__ and __defineSetter__, but I have never gotten this to work (HTMLElement.prototype.__d
However, I did get a response from HTMLElement.prototype.curr
Calling the function explicitly (ie. document.defaultView.getCo
What am I doing wrong in my prototype function?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way, using defineGetter for the currentStyle is much better for you than the older syntax because it enables currentStyle as a property of elements rather than as a function, so it's then cross-browser with IE. But I guess you knew that.
ASKER
Odd... yesterday, when I was told about these abilities of Mozilla, I got this line:
HTMLElement.prototype.__de fineGetter __("curren tStyle", function() { return document.defaultView.getCo mputedStyl e(this, null); });
And I couldn't get it to work. Today, after having pasted your line, and noted the similarities, I again tried the old line. And it did work. Must have done something odd yesterday.
Anyway, thanks for clearing this up!
HTMLElement.prototype.__de
And I couldn't get it to work. Today, after having pasted your line, and noted the similarities, I again tried the old line. And it did work. Must have done something odd yesterday.
Anyway, thanks for clearing this up!
Yeh the prototying abilities of Mozilla are awesome!!
Any Object can be prototyped as you know, not just Core Javscript objects! If only people knew about the power of Mozilla.....
Any Object can be prototyped as you know, not just Core Javscript objects! If only people knew about the power of Mozilla.....
ASKER
If only Mozilla could have implemented currentStyle in the first place...
;)
;)