JavaScript代码在Safari中不起作用

时间:2013-10-29 01:38:45

标签: javascript safari

我的代码适用于Chrome和Firefox,但不适用于Safari。

这是一段代码:

var menu = document.getElementById("navigation1");
var already_moved = 0;
menu.onmouseover = function moveNavigation(menu) {
    if (already_moved == 0) {
        document.getElementById("navigation1").style.marginLeft = "0px";
        already_moved = 1;
    }
};

menu.onmouseleave = function moveBackNavigation(menu) {
    if (already_moved == 1) {
        //document.getElementById("navigation1").style.marginLeft = "-341px";
        closeMenu();
        already_moved = 0;
    }
};

function closeMenu(){
    setTimeout(function f(){
        document.getElementById("navigation1").style.marginLeft = "-341px";
        already_moved = 0;
        }, 2000);
};

此代码将菜单向左和向后移动。 感谢您的任何想法 - 如何让它在Safari中运行。

1 个答案:

答案 0 :(得分:0)

我想澄清你确实在Safari中启用了JavaScript,对吧? As shown here