首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

麻烦看下这段代码。为什么在firefox里点击超链接不跳转,而在IE中就跳转了。本人意愿是不跳转,该如何处理

2012-04-08 
麻烦看下这段代码。为什么在firefox里点击超链接不跳转,而在IE中就跳转了。本人意愿是不跳转HTML codehtml x

麻烦看下这段代码。为什么在firefox里点击超链接不跳转,而在IE中就跳转了。本人意愿是不跳转

HTML code
html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>image gallery</title>    <link rel="Stylesheet" href="styles/layout.css" type="text/css"/>    <script type="text/javascript">        function showPic(whichpic)        {            imgSource = whichpic.getAttribute("href");            placeholder = document.getElementById("placeholder");            placeholder.setAttribute("src",imgSource);                        var text = whichpic.getAttribute("title");            var description = document.getElementById("description");            description.firstChild.nodeValue = text;            //alert(description.childNodes[0].nodeValue);        }        function countBodyChildren()        {            var body_element = document.getElementsByTagName("body")[0];            nodeLength = body_element.childNodes.length;            alert(body_element.nodeType);//            for(i=0;i<nodeLength;i++)//            {//                alert(body_element.childNodes[i].nodeType);//            }        }        //window.onload = countBodyChildren;    </script></head><body>    <h1>Snapshots</h1>    <ul>        <li>            <a href="img/1.jpg" title="A fireworks display" onclick="return false;showPic(this);">Fireworks</a>        </li>        <li>            <a href="img/2.jpg" title="A cup of black coffee" onclick="showPic(this);return false;">Coffee</a>        </li>        <li>            <a href="img/3.jpg" title="A red,red rose" onclick="showPic(this);return false;">Rose</a>        </li>        <li>            <a href="img/4.jpg" title="The famous clock" onclick="showPic(this);return false;">Big Ben</a>        </li>    </ul><br /><br />    <img id="placeholder" src="img/1.jpg" alt="my image gallery" width="400px" height="300px" />    <p id="description">Choose an image.</p>    </body></html>


[解决办法]
有些关键字不要使用为好,参见
http://blog.csdn.net/net_lover/article/details/7162136
[解决办法]
var placeholder = document.getElementById("placeholder");//加个var就可以了

热点排行
Bad Request.