Help on simply javascript tabswitch please

Discussion in 'JavaScript' started by Basti, Jul 19, 2009.

  1. #1
    Hey,
    ive found this tabswitch a while back.
    I use it to switch between 2 Videoplayers which can been viewed here http://www.anime-movie-site.com/Galaxy-Express-999

    Problem is that its broken in IE, firefox is just fine

    but in ie 6/7
    - it switch the tab, but the other movie dont stop playing, like it does in firefox.

    in ie8
    once tab is clicked 1 player stands still and the other is always at the bottom of the browser window :/ if you scroll once clicked, you see it.

    I dont want to find something else, because i have the a href javascript codes often. Would be a pain to edit the movies again.


    I use this on the actual movies
    video #2 is display: none with css by default pageload.

    
    <ul class="movie_tabs">
    <li><a href="javascript:tabSwitch('tab_1', 'vid_1');" id="tab_1" class="active">English Subtitles</a></li>
    <li><a href="javascript:tabSwitch('tab_2', 'vid_2');" id="tab_2">English Dubbed</a></li>
    </ul>
    
    movies codes in divs
    
    PHP:
    and the js file
    
    function tabSwitch(new_tab, new_content) {  
       
    document.getElementById('vid_1').style.display = 'none';  
    document.getElementById('vid_2').style.display = 'none';  
    document.getElementById(new_content).style.display = 'block';     
          
      
    document.getElementById('tab_1').className = '';  
    document.getElementById('tab_2').className = '';  
    document.getElementById(new_tab).className = 'active';        
       
    } 
    
    PHP:
    Does anyone know how to make this work in IE? possibly 6,7,8

    Thanks,
    Seb
     
    Basti, Jul 19, 2009 IP
  2. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #2
    The movie won't stop playing because you only make it "invisible", so it will keep playing.

    if you'll change the value of vid_x to "" instead of changing its display to none it will stop.
     
    Oli3L, Jul 25, 2009 IP
  3. Basti

    Basti Active Member

    Messages:
    625
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    90
    #3
    Thank you, will try that out :) Would be one problem less if it works
     
    Basti, Jul 25, 2009 IP
  4. Basti

    Basti Active Member

    Messages:
    625
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    90
    #4
    Hmm this did not the trick.

    Firefox still was displaying fine, but in IE, once the second tab is clicked both player display and the first also dont stop playing

    Any more Ideas?
     
    Basti, Jul 29, 2009 IP
  5. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #5
    see if you can control playback externally - a lot of these flash players can interact with an external command. if so, append the command to the js that swaps tabs.

    view.sendEvent(ViewEvent.PLAY);

    i assume there's also .STOP - read your manual: http://developer.longtailvideo.com/trac/wiki/FlashApi



    failing that, reset the contents of the div on tab click
     
    dimitar christoff, Jul 30, 2009 IP