Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17732
| From | JJ <jaejunks@nah.meh> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: To catch an exception |
| Date | 2012-12-17 10:04 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <XnsA12CAE7AFCC69jj@0.0.0.15> (permalink) |
| References | <50cedccc$0$6950$e4fe514c@news2.news.xs4all.nl> |
"Tom de Neef" <tdeneef@qolor.nl> wrote:
> Can someone indicate what I do wrong here:
> {code}
> 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) };
> }
> }
> }
> }
> }
>
> {/code}
>
> The aim of the function is to remove style rules and it does what it
> is meant to do in IE and Chrome. Not so in FF. When the indicated
> statement is executed, FF will just give up. It jumps out of the
> function and out of the calling functions when the k-loop has reached
> the bottom sheet (with the 'fixed' styles loaded from an external
> stylesheet). Try..catch around help since then the function terminates
> properly and execution will continue. But why are they necessary? I
> have no idea how to read 'err' in FF.
> TIA
> Tom
The statement in the disabled try...catch shouldn't cause problem. What's
the exact exception error message when it occurs?
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