2014年3月24日 星期一

Lab 14 Create Image using DOM

<html>
 <head>
Click the button to call a photo<br />

<button onclick="build()">Try it</button>

<title>lab14</title>
 <script>
function build()
{
myImg =document.createElement("IMG")
myImg.setAttribute("id","imageOne")
myImg.setAttribute("src","http://airsnarf.shmoo.com/airsnarf.jpg")
docBody = document.getElementsByTagName("body").item(0)
docBody.appendChild(myImg)
}
window.onload=build
</script>
</head>
<body>
<br />
</body>
 </html>
Click the button to call a photo
lab14

沒有留言:

張貼留言