<script type="text/javascript">
function load(){
alert('hi!');
}
function click(){
var username=prompt('what is your name?','enter your name here.');
if(username && username!='enter your name here.')
alert('It is good to see you,'+username+'.');
}
</script>
<body onload="load()">
<div style="margin-top:50px;text-align:center">
<img onclick="click()" id="rockman" src="../Html/pic/QQ圖片20150625150634.jpg" alt="rockman" / height="250px" width="500px">
</div>
onclick="click()"改為下面的,要麼你的函數名就另外起一個。click是this對象的一個內置函數,你直接click()會調用img對象的內置click方法,而不是你定義的,除非明確指定了window作用域
<img onclick="window.click()" id="rockman" src="../Html/pic/QQ圖片20150625150634.jpg" alt="rockman" height="250px" width="500px">