简体   繁体   中英

JS Does not work on IE

i try to develop a page but does not work on IE.

This is the actual page:

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

You can use up and down arrow keys.It works on Google Chrome and Firefox but does not work on IE

This is the code :

<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>

What might be the reason ?

Internet explorer doesn't understand evt.keyCode , instead try:

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

switch(keyCode){
   //...
}
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) {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM