<a href="http://www.baidu.com" onmouseover=="turnOn();"  onmouseout="turnOff();"> 这样写有问题吗

解决方案 »

  1.   

    onmouseover=="turnOn();" 第一眼多了一个“=”
      

  2.   

    关键字在大小写
    var不能写成Var
    function不能写成Function
    Javascript是区分大小写的onmouseover=="turnOn();这里,用一个等于号就可以了我稍微改了一下<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript" src="jquery-1.2.6.min.js"></script>
    </head>
    <body onload="InitloadImg()">
    <script type="text/javascript">
    var img1 = "http://www.google.cn/intl/zh-CN/images/logo_cn.gif";
    var img2 = "http://www.baidu.com/img/baidu_logo.gif";
    var img = null;
    function InitloadImg()
    {
    img = document.getElementById("pic");
    img.src = img1;

    function turnOn()

    img.src = img2;

                    
    function turnOff()
    {
    img.src = img1;

    </script>
    <P>将鼠标放在下图上面,图片将被另一幅图片所代替,鼠标移走,图片又复原 <P> 
    <a href="http://www.baidu.com" onmouseover="turnOn();"  onmouseout="turnOff();"> 
    <img name="introduction" src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" id="pic">
    </a> 
    </body>
    </html>
      

  3.   

    <a href="http://www.baidu.com" onmouseover=="turnOn();"  onmouseout="turnOff();"> 多了一个 = 号
    --------->
    <a href="http://www.baidu.com" onmouseover="turnOn();"  onmouseout="turnOff();"> 
      

  4.   

    搞那么复杂干什么?
    <a href="http://www.baidu.com">
    <img name="introduction" src="原图.gif" onmouseover="this.src='新图.gif'" onmouseout="this.src='原图.gif'">  </a>