function doesnt work on explorer but work on other browsers why?

Discussion in 'JavaScript' started by macaela, Jul 19, 2011.

  1. #1
    Hi i have this function that works on all most of the browsers except explorer it gives me following error
    SCRIPT600: Unknown runtime error
    mypage.html, line 76 character 3 which is this line
      document.getElementById('rep').innerHTML=lit
    
    Code (markup):
    I have looked everywhere but i dnt seem to be able to fix the issue now the fucntion works in other browsers except explorer i used the explorer debug to show the erorr this how the function code call the above function i've seen places that said change paragraph to divs but i dnt have paragraphs?
    <SCRIPT TYPE="TEXT/JAVASCRIPT"> 
    function setup(ans) {
      lit = ''
      if (ans == 'Property') { 
      
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
      }
      
      if (ans == 'Location') {
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist" src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist" src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist"  src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist"  src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>'
    
      }
      
       if (ans == 'News') {
    	   
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>'
    
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>'
    
    lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>'
    	   
       } 
      
      document.getElementById('rep').innerHTML=lit
      
    }
    </SCRIPT>
    Code (markup):

     
    macaela, Jul 19, 2011 IP
  2. oltranzista

    oltranzista Peon

    Messages:
    34
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should first add semicolons to the end of each statement! JavaScript tries to figure out where each statement ends and the next one begins but it isn't that reliable and bugs can occur, google JavaScript Semicolon Insertion for more information on it.

    I also recommend using jQuery for DOM manipulation.

    See if this works (if not you should post all of your code.):

    <SCRIPT TYPE="TEXT/JAVASCRIPT"> 
    function setup(ans) {
        lit = '';
        if (ans == 'Property') { 
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmann30735.mp4\', \'hd.file\': \'videosdemo/hofmann30735hd.mp4\'})"><img class="images_playlist" src="house_images/hofmann30735tmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
        }
        
        if (ans == 'Location') {
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist" src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist" src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist"  src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/hofmorpeth.mp4\', \'hd.file\': \'videosdemo/hofmorpethhd.mp4\'})"><img class="images_playlist"  src="house_images/hofmorpethtmbleft_new.jpg"  alt="house" /></a></td></td></tr>';
        }
        
        if (ans == 'News') {
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>';
            
            lit = lit + '<tr><td  class="fodas" cellspacing="0"><a href="#" onClick="jwplayer().load({\'file\': \'videosdemo/videoblog.mp4\', \'hd.file\': \'videosdemo/videobloghd.mp4\'})"><img class="images_playlist" src="house_images/videoblogtmb_new.jpg"  alt="house" /></a></td></td></tr>';
        } 
        
        document.getElementById('rep').innerHTML=lit;
    }
    </SCRIPT>
    Code (markup):
     
    oltranzista, Jul 20, 2011 IP