javascript图像翻转问题

时间:2012-12-01 05:39:37

标签: javascript html

明天我有一份作业......我坚持特殊要求。我需要使用单独的脚本页面对我的HTML进行java脚本图像翻转。然后将页面链接到Html Head标签。

这是我的java脚本页面,而不是我使用标签中的功能,但仍然没有调用它。有什么建议吗?

这是javascript文件:

// Pre load images for rollover
function imgOver() 
{
    document.getElementById('logo').src="images/logo1.jpeg"; 
}

function imgOut() 
{
    document.getElementById('logo').src="images/logo.jpeg"; 
}

onclick=”window.print( ); return false;”

这是HTML:

<!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" xml:lang="en" lang="en">
    <head>
        <meta name="author" content="Teancum Clark" />
        <meta name="class" content="INFO 2450 - Web Content Design" />
        <meta name="section" content="001" />
        <meta name="project" content="expresswebpractice2a" />
        <meta name="due_date" content="11/07/2012" />
        <meta name="instructor" content="Kim Bartholomew" />
        <meta name="description" content="Description of the project here..." />
        <meta name="keywords" content="expweb2a" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>Home</title>
        <link href="mystyles.css" rel="stylesheet" type="text/css" />




            <script type="text/javascript" src="MyScript.js"></script>



    </head>

    <body>
        <div class="fl" id="wrapper">
            <div class="fl" id="content">
                <div class="fl" id="header">
                    <div class="fl" id="leftImage">
                        <a href="#" onmouseover="imgOver();" onmouseout="imgOut()">
                        <img id="logo" alt="logo" height="150" src="images/logo1.jpeg" width="110" />
                        </a>

                    </div>
                    <div class="fl" id="rightImage">
                        <img class="rightImage"src="Images/banner.png" alt="Pets R Us banner"/>
                    </div>
                </div> <!--header-->

                <div class="fl" id="left">
                    <a class="buttons fl" href="index.htm">Home</a>
                    <a class="buttons fl" href="AboutUs.htm">About</a>
                    <a class="buttons fl" href="Tributes.htm">Tributes</a>
                </div><!--left-->


                <div class="fl" id="right">
                    right
                </div><!--right-->

                <div class="fl" id="footer">
                    The great Pets R Us staff came and picked her up two hours later and I didn't even have to worry about feeding or watering "Sophie".
                    We now have a regular appointment every Saturday...
                    <br/>
                    <br/>
                    Yours, 
                    <br/>
                    Jewel Anderson, 
                    <br/>
                    Centerville, UT
                    <br/>
                    <a class="buttons fl" href="Tribute.htm">Read More?</a>     

                        <img class="center" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" />
                </div><!--footer-->

            <br style="clear:both; font-size:1px;" />
            </div><!--content-->
        </div><!--wrapper-->
    </body>
</html>

2 个答案:

答案 0 :(得分:0)

onclick=”window.print( ); return false;”

该行是非法的,导致您的脚本文件被忽略,删除它并且您的鼠标悬停/退出将开始工作

答案 1 :(得分:0)

问题在于: onclick=”window.print( ); return false;”

您正在使用花哨的引号,这会导致混乱。

试试这个: onclick="window.print( ); return false;";