IE7 returning toJSON instead of i: javascript

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Mar 2009
Posts: 1
Reputation: dpd is an unknown quantity at this point 
Solved Threads: 0
dpd dpd is offline Offline
Newbie Poster

IE7 returning toJSON instead of i: javascript

 
0
  #1
Mar 3rd, 2009
Hi all,

I'm not overly proficient at Javascript, but have fumbled my way through some tutorials to come up with the following code to create a tab mechanism.

It works perfectly in Firefox, Safari, Chrome and IE8. However, in IE6 and IE7 it fails to operate as of the 'for (var i in temp) {' line. It doesn't error out, it just doesn't perform any of the functions within the for.

Some things I've noted:
* In Firefox if I alert(i) below the for, then it alerts the numerical value of i correctly through the for loop.
* In IE7, however, alert(i) alerts the value 'toJSON' and nothing more. It never finds 'if (i <= maxlen) {' to be true as a result.

Any thoughts on what's going wrong here?


  1. function toggle_visibility(showid, hideids) {
  2. $(showid).style.display = 'block';
  3. // Change CSS
  4. var newcss = showid.split('_').join('');
  5. $(newcss).setAttribute("class", "tabselected");
  6. $(newcss).setAttribute("className", "tabselected");
  7.  
  8. if (hideids != '') {
  9. var temp = new Array();
  10. temp = hideids.split(',');
  11. var maxlen = (temp.length - 1);
  12. var i = 0;
  13. for (var i in temp) {
  14. if (i <= maxlen) {
  15. if (temp[i] != showid) {
  16. $(temp[i]).style.display = 'none';
  17.  
  18. var newcss = temp[i].split('_').join('');
  19. $(newcss).setAttribute("class", "tab2");
  20. $(newcss).setAttribute("className", "tab2");
  21. }
  22. } else {
  23. break;
  24. }
  25. }
  26. }
  27. }

And I'm calling it with

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. toggle_visibility('tab3', 'tab1,tab2');
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: IE7 returning toJSON instead of i: javascript

 
0
  #2
Mar 5th, 2009
have you seen my tab menu script in javascript code snippets section? i like it so much, i use it in professional applications.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC