![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi! Ok, so I have small problem and can't find solution to it.. Is there any way to check if an object has defined setter? In other words - if it's value can be changed? Small example: var el = document.getElementById('element'); el.style = "smth"; Browser will throw exception, I can use try..catch but is there way to just write a function like hasSetter() ? |
#3
| |||
| |||
|
|
Ok, so I have small problem and can't find solution to it.. Is there any way to check if an object has defined setter? In other words - if it's value can be changed? |
|
Small example: var el = document.getElementById('element'); el.style = "smth"; Browser will throw exception, |
|
I can use try..catch but is there way to just write a function like hasSetter() ? |
#4
| |||
| |||
|
|
Piotr K wrote: Ok, so I have small problem and can't find solution to it.. Is there any way to check if an object has defined setter? In other words - if it's value can be changed? No, but you can test whether the value changed after you tried. Small example: var el = document.getElementById('element'); el.style = "smth"; Browser will throw exception, BAD. The `style' property of element objects is implemented as a reference to an object, and its interface specifies it as being read-only. I can use try..catch but is there way to just write a function like hasSetter() ? No. Adhering to standards stands the best chance of not throwing an exception here. http://www.w3.org/TR/DOM-Level-2-Sty...mentCSSInlineS... PointedEars -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs, <f806at$ail$1$8300d... (AT) news (DOT) demon.co.uk |
![]() |
| Thread Tools | |
| Display Modes | |
| |