เวลานี้เคสขนาดเล็กมีชื่อว่าและมีอีกกรณีหนึ่งที่ตอบสนองต่อเหตุการณ์เมื่อคลิกที่ภาพ รหัสมีดังนี้:
การคัดลอกรหัสมีดังนี้:
<script type = "text/javascript">
ฟังก์ชั่น onloadEvent () {
var _td = document.getElementById ("A1");
var _img = document.createElement ("IMG");
_img.setAttribute ("id", "floatimage");
_img.setAttribute ("src", "icon.png");
_img.setAttribute ("onclick", "clickimage ()");
_img.onclick = function () {// ตอบสนองต่อเหตุการณ์เมื่อคลิก
การแจ้งเตือน ("คลิก");
//window.location = "http://baidu.com"; กระโดด url
-
_td.AppendChild (_img);
-
</script>
เพียงโทรหาฟังก์ชั่นด้านบนในเหตุการณ์ ONLOAD ในร่างกาย