我尝试开发一个页面,但在IE上不起作用。

这是实际的页面:

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

您可以使用向上和向下箭头键。它可以在Google Chrome和Firefox上运行,但不能在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>


可能是什么原因?

最佳答案

Internet Explorer无法理解evt.keyCode,请尝试:

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

switch(keyCode){
   //...
}

07-24 09:30