Bug Tracker

Modify

Ticket #2245 (closed bug: worksforme)

Opened 6 years ago

Last modified 6 years ago

getComputedStyle throwing error in all browsers

Reported by: cloudsteph Owned by:
Priority: major Milestone: 1.2.4
Component: core Version: 1.2.2
Keywords: getComputedStyle Cc:
Blocking: Blocked by:

Description

Error reporting in FF2, IE7, IE6, Safari 4. Not using the curCSS function at present in my webpages so unsure if it is affecting the function itself but it does cause error pop-ups to appear in IE6 while preventing code from validating in all browsers.

Error details reported in Firebug while running JQuery 1.2.2 [uncompressed version]:

uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame ::  file:///Y:/IGS/Programming/Site/www/templates/js/jquery-122min.js :: anonymous :: line 22" data: no]

Line 0

Not sure if  http://dev.jquery.com/ticket/1779 or  http://dev.jquery.com/ticket/1661 are related as I've tried applying fixes for both to this issue without success.

Change History

comment:1 Changed 6 years ago by cloudsteph

This error is now also appearing in 1.2.3.

uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame ::  file:///Y:/IGS/Programming/Site/www/templates/js/jquery-1.2.3.js :: anonymous :: line 876" data: no]

Line 0

comment:2 Changed 6 years ago by davidserduke

Do you have a simple test case that causes it? I've never seen this happen myself.

comment:3 Changed 6 years ago by cloudsteph

comment:4 follow-up: ↓ 5 Changed 6 years ago by davidserduke

  • Milestone changed from 1.2.2 to 1.2.4

Testing in IE this bug is in your code in your init() function.

function init(){
 var divArray = new Array("detail_1", "detail_2", "detail_3", "detail_4","hide_1","hide_2","hide_3","hide_4");

 for(i=0;i<=8;i++){
   var theElement = document.getElementById(divArray[i]);
   $(theElement).hide();
 }
}

If you look you'll see your array has 8 elements but your loop goes from 0 to 8 inclusive. So what happens on the last loop is the getElementById returns null and $(null) == $(document) so it is trying to hide the document element itself which fails since it has no 'style' property.

Try changing your code to "< 8" instead of "<= 8" or probably better "< divArray.length".

comment:5 in reply to: ↑ 4 Changed 6 years ago by cloudsteph

Thanks, I really appreciate your help. Still very much the JS novice.

Replying to davidserduke:

Testing in IE this bug is in your code in your init() function.

function init(){
 var divArray = new Array("detail_1", "detail_2", "detail_3", "detail_4","hide_1","hide_2","hide_3","hide_4");

 for(i=0;i<=8;i++){
   var theElement = document.getElementById(divArray[i]);
   $(theElement).hide();
 }
}

If you look you'll see your array has 8 elements but your loop goes from 0 to 8 inclusive. So what happens on the last loop is the getElementById returns null and $(null) == $(document) so it is trying to hide the document element itself which fails since it has no 'style' property.

Try changing your code to "< 8" instead of "<= 8" or probably better "< divArray.length".

comment:6 Changed 6 years ago by davidserduke

  • Status changed from new to closed
  • Resolution set to worksforme

Quite welcome. Glad your problem was fixed.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.