A.html
<script type="text/javascript" src="A.js">
<form>
<input type="button" name="test" value="Click me" onclick="inform()">
</form>
A.js
function inform(){
alert("You have activated me by clicking the grey button! Note that the event handler is added within the event that it handles, in this case, the form button event tag")
}
全部一次
<script type="text/javascript">
function inform(){
alert("You have activated me by clicking the grey button! Note that the event handler is added within the event that it handles, in this case, the form button event tag")
}
</script>
<form>
<input type="button" id="button" name="test" value="Click me" onclick="inform()">
</form>
調用函數在JavaScript
if(condition in which you want onclick to b called)
document.getElementById('button').click();
我認不出你想實現..你在a.html一個按鈕,並希望它調用在定義的函數是什麼。 js什麼時候點擊? – Marty 2011-05-03 03:24:33
我相信他想要一個名爲'res'的函數,就像按鈕上的'onclick'動作一樣。 – 0x60 2011-05-03 03:25:59
和@sira,你不必留言。 – pavium 2011-05-03 03:26:02