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 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    a NewBie "Duhhh" kinda question

    Hi Folks,

    I want to use javascript to manage a single "Return to Index Page" kind of button.
    I also want to use two different images for this button. A <onMouseOver> image as well as an <OnMouseOut> image.
    The button is going to be placed on all the html pages in the directory, and will also probably be at several locations in each of the pages.
    It occurs to me that I SHOULD put the javascript code in a single file... say "Return.js" but I don't know how. It makes sense, because I wouldn't have to rewrite the stuff all over the place.
    So... that's really two questions:
    1)
    How do I make such a "Return.js" file?
    2)
    How do I refer to a 'function' in the ".js" file from an HTML page, and importantly... can I refer to it more than once and still retain the animation?

    Many thanks,
    Paul

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    you should write the event handler and the function called anyway in all the pages, so probably, if you mean a single button, maybe it is easier to use

    <img src="normalbut.gif" onmouseover="this.setAttribute('src','rolloverbut.gif')" onmouseout="this.setAttribute('src','normalbut.gif')">

    Or you wanna know how to write a generic rollover code?

    If you have a js code which is to be used in several pages, just put the code (without the <script type="text/JavaScript"> and </script> markers) in an external JS file, name it whichever (say myscript.js). Put this in the HEAD of each page.
    <script type="text/javascript" src="myscript"></script>
    Last edited by Kor; 04-11-2005 at 06:01 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Kor...

    I've followed your suggestion, and it works just as I had hoped it would...
    as a matter of fact... even better than I had hoped.

    Thanks again,

    and by the way... Romania in the EU.. why not? How do I support such a thing, anyway?

    Regards,
    Paul

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Romania in the EU.. why not? How do I support such a thing, anyway?
    If you are a member in the European Parliament, vote for us on the 13th of April. Or lobby for us to a member of EU Parliament...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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