Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17738
| Message-ID | <1393459.e97MPUDCx7@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2012-12-17 15:25 +0100 |
| Subject | Re: To catch an exception |
| Newsgroups | comp.lang.javascript |
| References | <50cedccc$0$6950$e4fe514c@news2.news.xs4all.nl> <XnsA12CAE7AFCC69jj@0.0.0.15> <50cf22cc$0$6847$e4fe514c@news2.news.xs4all.nl> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
Tom de Neef wrote:
> "JJ" <jaejunks@nah.meh> schreef […]
>> "Tom de Neef" <tdeneef@qolor.nl> wrote:
>>> Can someone indicate what I do wrong here:
>>> {code}
^^^^^^
BTW, this is unnecessary and distracting here.
>>> function removeStyleElement(scope) {
>>> var sheets = document.styleSheets,k,sheet,rules,j,rule,s;
>>> scope = scope.toLowerCase();
>>> for (k=sheets.length-1;k>=0;k--) { // skip the 'fixed' styles in
>>> sheet[0]
>>> sheet = sheets[k];
>>> // try {
>>> rules = (sheet.cssRules)?sheet.cssRules:sheet.rules; //<<=====
>>> // }
>>> // catch (err) {return};
>>> if (rules) {
>>> for (j=0;j<rules.length;j++) {
>>> rule = rules[j];
>>> s = (rule.selectorText)?rule.selectorText:rule;
>>> if (s.toLowerCase() == scope) {
>>> if (sheet.removeRule) {sheet.removeRule(j)}
>>> else { if (sheet.deleteRule) sheet.deleteRule(j) };
>>> }
>>> }
>>> }
>>> }
>>> }
>>> […]
>>
>> The statement in the disabled try...catch shouldn't cause problem. What's
>> the exact exception error message when it occurs?
>
> There is no error message. When FF reaches that line, it jumps out and
> stops execution (doesn't pick up in an enclosing block).
Highly unlikely.
> With the try .. catch included, it will jump to the catch statement. But I
> do not know how to get information from the 'err' object.
By inspecting it? By document.write()ing, window.alert()ing,
console.log()ing it before you return?
> The debugger doesn't show it.
It should, and it does, unless its not showing it is related to your bad
code style (you have the “catch” keyword, its /Block/ statement, and the
“return” statement in the block on the same line).
PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
To catch an exception "Tom de Neef" <tdeneef@qolor.nl> - 2012-12-17 09:50 +0100
Re: To catch an exception Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-17 10:44 +0100
Re: To catch an exception JJ <jaejunks@nah.meh> - 2012-12-17 10:07 +0000
Re: To catch an exception "Tom de Neef" <tdeneef@qolor.nl> - 2012-12-17 15:23 +0100
Re: To catch an exception Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-17 15:33 +0100
Re: To catch an exception John G Harris <john@nospam.demon.co.uk> - 2012-12-17 15:28 +0000
Re: To catch an exception Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-17 17:32 +0100
Re: To catch an exception John G Harris <john@nospam.demon.co.uk> - 2012-12-18 17:01 +0000
Re: To catch an exception Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-29 14:41 +0100
Re: To catch an exception Dr J R Stockton <reply1252@merlyn.demon.co.uk.invalid> - 2012-12-30 16:23 +0000
Re: To catch an exception Dr J R Stockton <reply1251@merlyn.demon.co.uk.invalid> - 2012-12-18 16:35 +0000
Re: To catch an exception Andrew Poulos <ap_prog@hotmail.com> - 2012-12-19 22:15 +1100
Re: To catch an exception Patricia Shanahan <pats@acm.org> - 2012-12-17 07:18 -0800
Re: To catch an exception JJ <jaejunks@nah.meh> - 2012-12-17 10:04 +0000
Re: To catch an exception "Tom de Neef" <tdeneef@qolor.nl> - 2012-12-17 14:48 +0100
Re: To catch an exception Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-17 15:25 +0100
Re: To catch an exception Tim Streater <timstreater@greenbee.net> - 2012-12-17 16:03 +0000
Re: To catch an exception Scott Sauyet <scott.sauyet@gmail.com> - 2012-12-18 08:26 -0800
Re: To catch an exception Bart Van der Donck <bart@nijlen.com> - 2012-12-30 08:42 -0800
csiph-web