<!DOCTYPE?HTML>
<html>
<head>
??<meta?charset="utf-8"?/>
</head>
<body>
??<h1>圖片轉(zhuǎn)換</h1>
??<ul>
????<li>
??????<a?href="images/pic1.jpg"?onclick="showPic(this);return?false">圖片1</a>
????</li>
????<li>
??????<a?href="images/pic2.jpg"?onclick="showPic(this);return?false">圖片2</a>
????</li>
????<li>
??????<a?href="images/pic3.jpg"?onclick="showPic(this);return?false">圖片3</a>
????</li>
????<li>
??????<a?href="images/pic4.jpg"?onclick="showPic(this);return?false">圖片4</a>
????</li>
??</ul>
?<img?src="images/pic1.jpg"id="placeholder"?alt="my?image?gallery"?/>
?<style?type="text/css">
?#placeholder{
??width:?600px;
??height:?400px;
??border:?1px?solid?#fff;
?}
?</style>
??<script>
????function?showPic(whichpic){
????????var?source=whichpic.getAttribute("href");
????????var?placeholder=document.getElementById("placeholder");
????????placeholder.setAttribute("src",source);
????}
????function?countBodyChildren()?{
??????var?body_element?=?document.geElementsByTagName("body")[0];
??????alert?(body_element.childNodes.length);
????}
????window.onload?=?countBodyChildren;
??</script>
</body>
</html>
大神們幫我看看為什么 無法在頁面加載后彈出alert
anfly
2016-08-01 14:11:31