Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts

    Doesn't work in internet Explorer!? (I'm using IE8)

    I am hoping that someone can figure out why this simple javascript works fine in Firefox, but not in IE8. I appreciate any help. PS: I see it DOES work in IE9... but I can't use it if I cannot make it work in IE8 as well. Sincerely, Buffmin

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>  
    <title>test</title>  
    <script type="text/javascript" src="jquery-1.6.2.js"></script> 
    <script type="text/javascript">
    $(document).ready(function() { 
       switches = $('#switches > li');     
       slides = $('#slides > div');     
       switches.each(function(idx) {          
           $(this).data('slide', slides.eq(idx));        
        }).hover(         
        function() {          
           switches.removeClass('active');             
           slides.removeClass('active');                          
           $(this).addClass('active');               
           $(this).data('slide').addClass('active');         
        });     
        }); 
    </script>  
    <style type="text/css">  
    #switches .active {   font-weight: bold; }  
    #slides div {   display: none; }  
    #slides div.active {   display: block; }  
    </style> 
    </head> 
    <body>  
    <ul id="switches">  
     <li class="active">First slide</li>   
     <li>Second slide</li>   
     <li>Third slide</li>   
     <li>Fourth slide</li> 
     </ul> <div id="slides">   
     <div class="active">Well well.</div>   
     <div>Oh no!</div>   
     <div>You again?</div>   
     <div>I'm gone!</div> </div>  
     </body> 
     </html>
    Last edited by Buffmin; 08-22-2011 at 09:05 PM.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    .data() is not supported by Internet Explorer when using XHTML.

    Note that this method currently does not provide cross-platform support for setting data on XML documents, as Internet Explorer does not allow data to be attached via expando properties.

  • Users who have thanked devnull69 for this post:

    Buffmin (08-22-2011)

  • #3
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    Thank you very much. Doctype again!!!


  •  

    Posting Permissions

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