Advanced Search

Results 1 to 6 of 6

Thread: MSIE Doesn't support getelementbytag..any ideas?

  1. #1
    Join Date
    Jul 2013
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default MSIE Doesn't support getelementbytag..any ideas?

    Greetings, September 4th 2013

    I am presently attempting to alter multiple div styles from hidden to visible as I select a button that loads a specific id to a function and the button id serves as id for the div as well and all the div's appear as they should in "Fire Fox", "Safari" However, I've learned that MSIE doesn't support the getelementByTag and other routines reference the div ids so changing accordingly is out as an option. I've attempted document.all, however, the result hasn't worked as a variable in the id of getelementbyid rather it reports as null !...Any ideas? Again, the id's of the div's are the identical to the id's of the css buttons All goes well however "tag.style.visibility" isn't recognized and null..I've included some messy code below

    Appreciatively,
    Ted

    Code:
    var tag, tags;
          
    	  //alert(document.all.length);
         for(i = 0; i < document.all.length; i++)
            {
    		   tag = document.all(i).getAttribute('id');
    		   tag2 = document.all(i).getAttribute('name');
    		   //alert(tag+" <==IE==> "+tag2+" ==choosen one===>"+thechosenone.id);
    	     if(tag==thechosenone.id && tag2=='contentarea'){
    		 	   alert(tag+"<< == >>"+thechosenone.id);
    			   //tag.style.visibility = 'visible';
    			   //tag2.style.visibility = 'hidden';
    			   document.getElementById('contentarea1').style.visibility = 'visible';
    			   //alert(tag(i).style.visibility);
    		 	if (tag==thechosenone.id) {
    				alert('in here');
    				if (tag.style.visibility == 'hidden') {
                        tag.style.visibility = 'visible';
                                   }
                    else {
                        tag.style.visibility = 'hidden';
                         }
                 }else {
    			 	   //if(tag2=='contentarea'){
                        tag.style.visibility = 'hidden';
    					                      // }
                       }
    		 	//alert(tag+" <==IE==> "+tag2);
    			//alert('match');
               //tags = tags + "\r" + tag;
    		                                                 }
            }
    Last edited by traq; 09-05-2013 at 01:43 AM. Reason: please use BBCode tags to format your post

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,627
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by tedteeter View Post
    ... I've learned that MSIE doesn't support the getelementByTag
    Right. No other browser does, either, AFAIK. getElementsByTagName might be what you're looking for?

    Beyond that, this:
    Quote Originally Posted by tedteeter View Post
    I am presently attempting to alter multiple div styles from hidden to visible as I select a button that loads a specific id to a function and the button id serves as id for the div as well
    ...makes me suspect you might be trying to assign the same id to multiple elements? This is illegal in HTML (every id must be unique - if other browsers are allowing this, then -WWNC- IE is the one that got it right). You should use a classname or data- attribute instead.

    You might also consider making a reduced test case using an online tool like jsfiddle to help us understand your problem further.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  3. #3
    Join Date
    Jul 2013
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    traq,

    You are correct it is the "getElementsByTagName" and you are further correct that I may be confusing the id's so I did attempt applying multiple id's to the div's as it is legal an has worked in the past. The below is working out great! However the for loop isn't keeping the others hidden as I click through the buttons. The id's correctly allow the appearance of the div however the previously invoke div doesn't disappear and they simply stack atop each other?...any ideas?

    document.all(i).style.visibility='visible';
    Last edited by tedteeter; 09-05-2013 at 03:02 AM.

  4. #4
    Join Date
    Jul 2013
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    traq,

    the below is what I have and the divs appear, however, they yet to disappear while at the bottom of the routine there is an if statement commented out which retains an element for index increment that will change the to hidden. Any ideas?

    Appreciatively,
    ted
    Code:
    var tag, tags;
          // or you can use var allElem=document.all; and loop on it
          tags = "The tags in the page are:"
    	  //alert(document.all.length);
         for(i = 0; i < document.all.length; i++)
            {
    		   tag = document.all(i).getAttribute('id');
    		   tag2 = document.all(i).getAttribute('name');
    
    	     if(tag==thechosenone.id && tag2=='contentarea'){
      
    		 	if (tag==thechosenone.id) {
    				alert(document.all(i).style.visibility);
    				if (document.all(i).id==thechosenone.id){
                            document.all(i).style.visibility = 'visible';
                                                                 }
                             else {
                                   document.all(i).style.visibility = 'hidden';
                                   }
    
                 }else {
    			 	   //if(tag2=='contentarea'){
                        //document.all(i).style.visibility = 'hidden';
    					document.all(i).style.visibility='hidden';   
                       }
    				   				//if(i==40){
    					//document.all(38).style.visibility='hidden';
    				                          //}
    		 	
    		    } 
            }
    Last edited by traq; 09-06-2013 at 01:57 AM. Reason: Please USE BBCode tags :)

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,627
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I've got to run right now but I'll look at your code when I get home this afternoon. John might be able to help as well.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  6. #6
    Join Date
    Jul 2013
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    traq, September 5th 2013

    Okay! after having walked away from the project for a night I reviewed the code an completed a simplistic fix to the above "Messy Code" and have included it below for readers that may become confused as I did!...Your assistance is very valued and appreciated, much thanks :-)
    Ted
    Code:
          var tag, tags;
          // or you can use var allElem=document.all; and loop on it
          tags = "The tags in the page are:"
        for(i = 0; i < document.all.length; i++)
            {
    		   tag = document.all(i).getAttribute('id');
    		   tag2 = document.all(i).getAttribute('name');
    	    if(tag==thechosenone.id && tag2=='contentarea'){
          	   document.all(i).style.visibility='visible';
         		 }else{
    		 	       if(tag2=='contentarea'){
                          document.all(i).style.visibility='hidden';
    					                       }
    
    		    } 
            }
    Last edited by traq; 09-06-2013 at 01:58 AM.

Similar Threads

  1. Featured Content Glider: IE doesn't render...any ideas?
    By listerdl in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-25-2011, 09:05 AM
  2. Replies: 7
    Last Post: 01-01-2011, 05:15 PM
  3. Replies: 1
    Last Post: 05-19-2009, 12:52 PM
  4. is it true that ie7 doesn't support innerHTML?
    By smansakra in forum JavaScript
    Replies: 2
    Last Post: 12-03-2008, 08:45 AM
  5. Object doesn't support this property or method
    By joseph_russell in forum JavaScript
    Replies: 4
    Last Post: 05-03-2007, 07:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •