Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with a simple script...

    I need help on a rollover script...

    Here's the mark-up. Can someone tell me what I did wrong?


    <!-- Hidden Script

    var d = newData ()
    var name = d.mouseOver; mouseOut

    function mouseOver()
    {
    document.r1.src ="epee1.png"
    }
    function mouseOut()
    {
    document.r1.src =rapier1.png"

    // End of Hidden Script -->


    (I know this is pretty simple, but I just started scripting in Java like 2 days ago...)
    Last edited by SerenadeSP; 10-13-2005 at 01:00 AM.
    ...Orthonistic...

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script type="text/javascript">
    <!--
    function mouseOver()
    {
    document.r1.src ="epee1.png"
    }
    function mouseOut()
    {
    document.r1.src ="rapier1.png"
    }
    //-->
    </script>
    </head>
    
    <body>
    <a href="#" onmouseover="mouseOver()" onmouseout="mouseOut()"><img src="rapier1.png" alt="" name="r1"></a>
    </body>
    </html>
    I personally wouldn't use Javascript for a simple image rollover. I would use CSS. You might want to pass variables to your function so you don't end up having like 5 different functions that do the same thing with different names.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script type="text/javascript">
    <!--
    function changeImages(where,what){
    document.getElementById(where).src=what;
    }
    //-->
    </script>
    </head>
    
    <body>
    <a href="#" onmouseover="changeImages('r1','epee1.png')" onmouseout="changeImages('r1','rapier1.png')"><img src="rapier1.png" alt="" name="r1" id="r1"></a>
    </body>
    </html>
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •