顯示具有 [HTML] 標籤的文章。 顯示所有文章
顯示具有 [HTML] 標籤的文章。 顯示所有文章

2012年11月24日 星期六

滑鼠移上切換圖片

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
       

            icon = new Image();
            icon.src = "../image/1.png";
            icon2 = new Image();
            icon2.src = "../image/2.jpg";
            icon3 = new Image();
            icon3.src = "../image/3.jpg";
            icon4 = new Image();
            icon4.src = "../image/4.png";
            function showImages(obj) {
                // DOM
               // var theImg = document.getElementById("myID");
                // theImg.src = obj;
                // BOM
                document.images[0].src = obj;
        }
    </script>
</head>
<body>
<a href="#" onmouseover="showImages(icon.src)">icon1</a> | <a href="#" onmouseover="showImages(icon2.src)">icon2</a> | <a href="#" onmouseover="showImages(icon3.src)">icon3</a> | <a href="#" onmouseover="showImages(icon4.src)">icon4</a>
<hr />
<img id="myID" src="../image/1.png" width="200px" />
</body>
</html>

2012年11月23日 星期五

置換網頁,不出現上一頁

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
    </script>
</head>
<body>
    <input type="button" value="href"  onclick="location.href='http://www.yahoo.com.tw'"/>
    <input type="button" value="replace"  onclick="location.replace('http://www.yahoo.com.tw')"/>
</body>
</html>



通常用reload會出現上一頁的按鈕讓使用者回去前一頁,

但今天如果不想讓使用者回前一頁的話,

可以使用replace()的方式就不會有這個問題出現