2014-12-04 77 views
0

這個腳本在IE瀏覽器中失敗,彈出窗口,但關閉按鈕不工作,它在firfox和谷歌瀏覽器中工作正常。彈出式關閉按鈕在Internet Explorer中不起作用?

#note { 
    position: relative; 
    z-index: 101; 
    top: 0; 
    left: 0; 
    right: 0; 
    background: #fde073; 
    text-align: center; 
    line-height: 2.5; 
    overflow: hidden; 
    -webkit-box-shadow: 0 0 5px black; 
    -moz-box-shadow: 0 0 5px black; 
    box-shadow:   0 0 5px black; 
} 


<div id="note"> 
    You smell good. <a id="close">[close]</a> 
<script> 
close = document.getElementById("close"); 
close.addEventListener('click', function() { 
    note = document.getElementById("note"); 
    note.style.display = 'none'; 
}, false); 
</script></div> 
+0

這是可以在其他瀏覽器中使用嗎? – 2014-12-04 05:17:45

+0

根據用戶在Firefox和Chrome中工作。 – AaronS 2014-12-04 05:18:32

+0

您正在測試什麼版本的Internet Explorer? – AaronS 2014-12-04 05:26:36

回答

1

JavaScript並不是跨瀏覽器的支持,使用jQuery代替

$("#close").on('click', function() { 
    $("#note").hide(); 
}); 
2

變化密切變量,接近是一個事件不變量。

<script> 
divclose = document.getElementById("close"); 
divclose.addEventListener('click', function() { 
    note = document.getElementById("note"); 
    note.style.display = 'none'; 
}, false); 
</script> 
+0

現在彈出窗口關閉罰款。 – 2014-12-05 02:14:38

+0

我爲我的部門創建了一個主頁,該頁面腳本訪問正常的辦公室服務器,但從服務器訪問網頁時出現問題,但從我的電腦打開時工作正常。它需要任何特殊服務器? – 2014-12-07 02:15:59

+0

檢查apache服務器版本或PHP版本。你有沒有使用任何PHP代碼? – Muthukumar 2014-12-08 06:18:32