2014年4月12日 星期六

Lab 14 Create Image using DOM

<html>
<head>
<body>
<p>click the button to call the picture</p>
<button onclick="build()">Try it</button>
</body>
    <meta content="text/html; charset=ISO-8859-1"
    http-equiv="content-type">
    <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)


}

    </script>
    </head>
    <body>
<br>
</body>
</html>

沒有留言:

張貼留言