Reply
IE stylesheet object problem
Old 12-30-2008, 08:50 AM IE stylesheet object problem
pealo86's Avatar
Webmaster Talker

Posts: 586
Name: El Phantasmo
Location: England, north west
Trades: 0
Im trying to create a script that will edit css rules in both FF and IE, but IE just isn't having any of it! I get an error message saying that
Quote:
'the object doesn't support this property or method'.
Here is my code, can anybody help?

Code:
var styleSheet = document.styleSheets[1];

if (styleSheet.rules)
   {
      var pAbout1 = styleSheet.rules[20].style;
      var pAbout2 = styleSheet.rules[22].style;
      var pAbout3 = styleSheet.rules[23].style;
   }

else
   {
      var pAbout1 = styleSheet.cssRules[20].style;
      var pAbout2 = styleSheet.cssRules[22].style;
      var pAbout3 = styleSheet.cssRules[23].style;
   }
   
pAbout2.setProperty ('display', 'none', '');
pAbout3.setProperty ('display', 'none', '');
pealo86 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 12-30-2008, 07:55 PM Re: IE stylesheet object problem
chrishirst's Avatar
Super Moderator

Posts: 21,624
Location: Blackpool. UK
Trades: 0
on which line?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-30-2008, 07:58 PM Re: IE stylesheet object problem
pealo86's Avatar
Webmaster Talker

Posts: 586
Name: El Phantasmo
Location: England, north west
Trades: 0
lol sorry, the one with

"pAbout2.setProperty ('display', 'none', '');"
pealo86 is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 08:01 PM Re: IE stylesheet object problem
pealo86's Avatar
Webmaster Talker

Posts: 586
Name: El Phantasmo
Location: England, north west
Trades: 0
Hmmm that's wierd, Im testing it now and there's no error message?? Having said that, the css properties still aren't changing the way they should!

One thing I forgot to point out:
If I alert (pAbout3) it says 'Object', and if I alert (styleSheet.rules[23].cssText); it says 'undefined'.

How confusing??

Last edited by pealo86; 12-30-2008 at 08:15 PM..
pealo86 is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 08:14 PM Re: IE stylesheet object problem
chrishirst's Avatar
Super Moderator

Posts: 21,624
Location: Blackpool. UK
Trades: 0
I don't think the style.setProperty method has been implemented in most browsers. Sure it's the W3C approved method but hey

use the standard

objVar.display = "none"; instead
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-30-2008, 08:29 PM Re: IE stylesheet object problem
pealo86's Avatar
Webmaster Talker

Posts: 586
Name: El Phantasmo
Location: England, north west
Trades: 0
Ahhhh maaaaaaaaaaaan Bill Gates and his never ending armies of darkness strikes again!

Thanks anway!
pealo86 is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 08:57 PM Re: IE stylesheet object problem
stevej's Avatar
Professional Multitasker

Posts: 991
Location: In a flying house
Trades: 0
Technically, it's not Bill Gates' fault. It's the browser's fault.

- Steve
stevej is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to IE stylesheet object problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.15460 seconds with 13 queries