2012-03-15 70 views
0

我嘗試開發一個頁面,但不適用於IE。JS在IE上不起作用

這是實際的頁面:

http://portal.sinemalar.com/tv/vestel/v1/artist/48029/1/1/1/2/

你可以用上下箭頭在谷歌Chrome和Firefox keys.It的作品,但在IE

不起作用

這是代碼:

<script type="text/javascript"> 
    {literal} 
    document.onload = function() { 
     MousePlayClick(); 
    } 
    {/literal} 
</script> 

<script type="text/javascript"> 
    {literal} 
    function artistKeyPress(evt) { 
     switch (evt.keyCode) { 
      case KEYS.UP: 
       if ($page > 1) { 
        $page--; 
        window.location.href = baseUrl + 'artist/' + $movieId + '/' + $vPage + '/' + $yPage + '/' + $slot + '/' + $page + '/'; 
       } 
       break; 
      case KEYS.DOWN: 
       $page++; 
       window.location.href = baseUrl + 'artist/' + $movieId + '/' + $vPage + '/' + $yPage + '/' + $slot + '/' + $page + '/'; 
       break; 
      case KEYS.RED: 
       window.location.href = baseUrl + 'detail/' + $movieId + '/' + $vPage + '/' + $yPage + '/' + $slot + '/'; 
       break; 
     } 
    } 
    {/literal} 
</script> 

<script>  

    var $slot = {$cursor}; 
    var $vPage = {$vPage}; 
    var $yPage = {$yPage}; 
    var $page = {$page}; 
    var $movieId = {$movieId}; 
    var $mp4Link = '{$mp4Link}'; 
    {literal}   
    document.onkeydown = function(evt) 
    { 
     artistKeyPress(evt); 
    } 
    {/literal} 
</script> 
<div class="main_content"> 
    <a href="{$portalPath}vestel/v1/artist/{$movieId}/{$prevPage}"><div class="yorum_yukari_ok ortala"></div></a> 
    {foreach value=artist key=key from=$artists} 
    <div class="yatay_kutu{if $key%2==0}_secili{/if}"> 
     <div class="yk_foto_cont_s"> 
      <img src="{$artist.picture}" height="132px" /> 
     </div> 
     <div class="yorum_a"> 
      <h2 class="bold">{$artist.nameSurname}<span class="sag">Puan:{$artist.rating}/10</span></h2> 
      {$artist.bio} 
     </div> 
    </div> 
    {/foreach} 
    <a href="{$portalPath}vestel/v1/artist/{$movieId}/{$nextPage}"><div class="yorum_asagi_ok ortala"></div></a> 
</div> 

可能是什麼原因?

+1

JavaScript和即彼此憎恨。 – javasocute 2012-03-15 16:14:37

+0

@javasocute,給我一個休息時間。 – 2012-03-15 16:15:42

+0

什麼不工作? – maialithar 2012-03-15 16:15:44

回答

2

Internet Explorer不明白evt.keyCode,而不是嘗試:

var keyCode = (window.event) ? window.event.which : evt.keyCode; 

switch(keyCode){ 
    //... 
} 
1
function artistKeyPress(evt) { 
    evt = evt || window.event; //handles IE which uses window.event for the details 
    var keyCode = evt.keyCode || evt.which; //handles cross browser with what key was pressed 
    switch (keyCode) {