[ 2 posts ]

Geoff

  • Username: geoff
  • Joined: Fri Feb 20, 2009 12:04 pm
  • Posts: 4
  • Offline
  • Profile

Javascript error in YUI on IE7

Post Posted: Wed Apr 22, 2009 5:48 pm
+0-
Hi:

I'm having some difficulties Javascript-wise on IE7 (and IE6, for that matter), and I've manage to reduce it to a test case.

Here's the code:
Code:
/*global YAHOO */

YAHOO.util.Event.onAvailable('optional',function () {
   var optional = YAHOO.util.Dom.get('optional');
   
   function ShowHide(e,obj) {
      YAHOO.util.Event.preventDefault(e);
      if (YAHOO.util.Dom.getStyle(optional, 'display') == 'none') {
         YAHOO.util.Dom.setStyle(optional, 'display', 'table');
         } else {
            YAHOO.util.Dom.setStyle(optional, 'display', 'none');
         }
      }
   
   YAHOO.util.Event.on('optionalShowHide', 'click', ShowHide);
   YAHOO.util.Dom.setStyle(optional,'display', 'none');

});


When I go to the page on IE7, and click the link with the ID 'optionalShowHide', I get this error from IE7 & the Script Debugger:

Quote:
A Runtime Error has occured.
Do you wish to Debug?

Line: 232
Error: Could not get the display property. Invalid argument.


It brings me to line 232 of dom.js, and the following line:

Code:
                            el.style[property] = val;

It's part of the setStyle method.

I don't know what's happening. Thoughts?

You can see the afflicted page here, and the full code is in the base.js file linked to from that page which is quoted in full above.

(The code works fine in FireFox 3 & Safari 3 & 4. It also fails in IE6, perhaps for the same reason.)

Thanks!

- geoff

Geoff

  • Username: geoff
  • Joined: Fri Feb 20, 2009 12:04 pm
  • Posts: 4
  • Offline
  • Profile

Re: Javascript error in YUI on IE7

Post Posted: Thu Apr 23, 2009 8:04 am
+0-
Well, I not only put this post in the wrong forum, but I found it's not a YUI problem, it's an IE7 problem. IE6 & 7 don't support "display:table", so it was choking on that. But unhiding the content by using "display:block" messed up the appearance on Safari & Firefox. So I changed "display:table" to "display:", and all is well with the world.

- geoff
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum