CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 28th, 2004, 09:04 AM
Chris.Nelson Chris.Nelson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Clifton Park, NY
Posts: 2 Chris.Nelson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Trouble with stylesheets in IE

I'm trying to manipulate a stylesheet to make elements appear and disappear on an HTML form. The code I've adapted from various sources works fine on non-IE browsers and sort of works on IE but there's something I don't understand and can't get to work.

My page starts:

Code:
        <style ID=\"xyzzy\" TYPE=\"text/css\">
        </style>
        <SCRIPT TYPE=\"text/javascript\">
        <!-- 
        function setClassAttr(c, a, v) {
          var agt=navigator.userAgent.toLowerCase();
          var e;
        // Style sheet management depends on browser.
        // See URL or URL
          if (agt.indexOf('gecko') != -1) {
            e=document.getElementById('xyzzy');
            e.sheet.insertRule(c + ' { ' + a + ': ' + v + '}', 
                               e.sheet.cssRules.length)
          }
          else if ( (parseInt(navigator.appVersion)>=4) 
          &&  (agt.indexOf('msie') != -1) ) {
            document.styleSheets['xyzzy'].addRule(c, a+':'+v);
          }
        }
        ...


And I use this to set "display" to "block" or "none" for subordinate elements when a checkbox is checked or unchecked.

As I said, this works for non-IE browsers but in IE, I click the first checkbox and nothing appears to happen. If I then click the background of the document, the elements appear. I've searched the web and MSDN for some way of flushing the stylesheet change or generating a Click from JavaScript and I can't find anything. I tried disabling and reabling the stylesheet and it didn't help. I tried moveBy(0,0) and it didn't help.

Is this a bug in IE or in my understanding of what should happen? If the former, how can I work around it? Can I generate a Click from JavaScript somehow? Redraw the window somehow? If the latter, what am I missing?

TIA.

Reply With Quote
  #2  
Old June 29th, 2004, 08:42 AM
Chris.Nelson Chris.Nelson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Clifton Park, NY
Posts: 2 Chris.Nelson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've fixed it, though the solution seems squirrely. It appears that IE doesn't fire onchange() handlers for checkboxes until the checkbox loses focus. I changed to onclick() and all is well.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Trouble with stylesheets in IE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT