2014-07-10 212 views
0

不知道爲什麼open按鈕的onclick函數沒有被調用。 任何幫助將是非常有用的Javascript函數沒有在按鈕的onclick事件中被調用

<html> 
<head> 
</head> 
<body> 
<script> 
function open(){ 
alert('gsfhdgf'); 
document.getElementById("overlay").style.display="block"; 
document.getElementById("fade").style.display="block"; 
} 

</script> 
<div id="fade" style="display:none"> 

<div id="overlay" style="display:none"> 
this is my content 
</div> 
</div> 
<button onclick="open()">Click Me!</button> 
</body> 
</html> 
+4

@ 1nflktd會發生什麼變化? –

+0

@NiettheDarkAbsol http://stackoverflow.com/questions/436411/where-is-the-best-place-to-put-script-tags-in-html-markup我不是說它的問題在這裏,我只是說它的*好*的做法,把它放在那裏,但把它放在任何地方,如果你想 –

回答

11

open已經作爲一個函數名(window.opendocument.open ......)

名稱的功能其他的東西(最好的東西有意義),它會工作。

+0

例如:http://codepen.io/paulroub/pen/kqhLE –

+0

@Niet the Dark Absol:謝謝mate.it沒有交叉我的思想;)現在工作得很好 – user3478137

0

如果你使用IE瀏覽器,有些版本沒有的屬性類型=「文/ JavaScript的」從未執行的標籤,而其他大多數的瀏覽器忽略。所以在IE中open()函數不存在。

相關問題