2013-10-29 152 views
0

我的代碼適用於Chrome和Firefox,但不適用於Safari。JavaScript代碼在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

什麼版本的Safari? – Evan

+0

我使用版本6.0.5(8536.30.1) – user2898056

+0

它如何在Safari中不起作用?完全沒有,或者它會做出意想不到的事情? – Evan

回答

0

我想澄清一下,您確實在Safari中啓用了JavaScript,對吧? As shown here