Results 1 to 2 of 2

Thread: Multiple Mouseover actions in one link?

  1. #1
    Join Date
    Mar 2007
    Posts
    28
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Multiple Mouseover actions in one link?

    1) Script Title: Roll Over Affect and ToolTip

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...tmltooltip.htm

    3) Describe problem:
    Can these two scripts be put into the same link, so that an image rolls over and a tooltip appears?

    Change Image Script from Javascript Kit
    <a href="#" onMouseover="changeimage(myimages[1],this.href)"><img src="Onsite/2_onsite.gif" border=0></a>

    Tooltip script to bring up text when the user cursors over the thumbnail from Dynamic Drive
    <a href="http://www.yahoo.com" onMouseover="ddrivetip('Visit Yahoo.com')";
    onMouseout="hideddrivetip()">Thumbnail</a>

    The url of the page I'm working on is:

    http://www.mastercraftmetals.com/onsitepix.html

    thank you
    teri

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,799
    Thanks
    2
    Thanked 420 Times in 414 Posts

    Default

    Code:
    <!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>
      <title></title>
    <base url="http://www.mastercraftmetals.com/"  />
    <style type="text/css">
    
    #dhtmltooltip{
    position: absolute;
    width: 150px;
    border: 2px solid black;
    padding: 2px;
    background-color: lightyellow;
    visibility: hidden;
    z-index: 100;
    /*Remove below line to remove shadow. Below line should always appear last within this CSS*/
    filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
    }
    
    </style>
    
    <script>
    
    /*Rollover effect on different image script-By JavaScript Kit (http://javascriptkit.com)Over 200+ free scripts here!*/
    
    function changeimage(towhat,url){
    if (document.images){
    document.images.targetimage.src=towhat.src
    gotolink=url
    }
    }
    function warp(){
    window.location=gotolink
    }
    
    </script>
    <script language="JavaScript1.1">
    var myimages=new Array()
    var gotolink="#"
    
    function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
    myimages[i]=new Image()
    myimages[i].src='http://www.mastercraftmetals.com/'+preloadimages.arguments[i]
    }
    }
    
    preloadimages("Onsite/onsite1.jpg","Onsite/onsite2.jpg","Onsite/onsite3.jpg","Onsite/onsite4.jpg","Onsite/onsite5.jpg","Onsite/onsite6.jpg","Onsite/onsite7.jpg","Onsite/onsite8.jpg","Onsite/onsite9.jpg","Onsite/onsite10.jpg","Onsite/onsite11.jpg","Onsite/onsite12.jpg","Onsite/onsite13.jpg","Onsite/onsite14.jpg","Onsite/onsite15.jpg","Onsite/onsite16.jpg","Onsite/onsite17.jpg","Onsite/onsite18.jpg","Onsite/onsite19.jpg","Onsite/onsite20.jpg","Onsite/onsite21.jpg","Onsite/onsite22.jpg","Onsite/onsite23.jpg","Onsite/onsite24.jpg","Onsite/onsite25.jpg","Onsite/onsite26.jpg","Onsite/onsite27.jpg","Onsite/onsite28.jpg","Onsite/onsite29.jpg","Onsite/onsite30.jpg","Onsite/onsite31.jpg","Onsite/onsite32.jpg","Onsite/onsite33.jpg","Onsite/onsite34.jpg")
    </script>
    </head>
    
    <body>
    <div class="centertext"><a href="javascript:warp()"><img src="http://www.mastercraftmetals.com/Onsite/onsite1.jpg" name="targetimage" border=0></a></div>
    <div class="textbold">
    <a href="#" onMouseover="changeimage(myimages[0],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/1_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[1],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/2_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[2],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/3_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[3],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/4_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[4],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/5_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[5],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/6_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[6],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/7_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[7],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/8_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[8],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/9_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[9],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/10_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[10],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/11_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[11],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/12_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[12],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/13_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[13],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/14_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[14],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/15_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[15],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/16_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[16],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/17_onsite.gif" border=0></a>
    <a href="#" onMouseover="changeimage(myimages[17],this.href)"><img onmouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)" onmouseout="hideddrivetip()" src="http://www.mastercraftmetals.com/Onsite/18_onsite.gif" border=0></a>
    </div>
    <div id="dhtmltooltip"></div>
    <script type="text/javascript">
    
    /***********************************************
    * Cool DHTML tooltip script-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    var offsetxpoint=-60 //Customize x offset of tooltip
    var offsetypoint=20 //Customize y offset of tooltip
    var ie=document.all
    var ns6=document.getElementById && !document.all
    var enabletip=false
    if (ie||ns6)
    var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
    
    function ietruebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    function ddrivetip(thetext, thecolor, thewidth){
    if (ns6||ie){
    if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
    if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
    tipobj.innerHTML=thetext
    enabletip=true
    return false
    }
    }
    
    function positiontip(e){
    if (enabletip){
    var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
    var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
    //Find out how close the mouse is to the corner of the window
    var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
    var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
    
    var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
    
    //if the horizontal distance isn't enough to accomodate the width of the context menu
    if (rightedge<tipobj.offsetWidth)
    //move the horizontal position of the menu to the left by it's width
    tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
    else if (curX<leftedge)
    tipobj.style.left="5px"
    else
    //position the horizontal position of the menu where the mouse is positioned
    tipobj.style.left=curX+offsetxpoint+"px"
    
    //same concept with the vertical position
    if (bottomedge<tipobj.offsetHeight)
    tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
    else
    tipobj.style.top=curY+offsetypoint+"px"
    tipobj.style.visibility="visible"
    }
    }
    
    function hideddrivetip(){
    if (ns6||ie){
    enabletip=false
    tipobj.style.visibility="hidden"
    tipobj.style.left="-1000px"
    tipobj.style.backgroundColor=''
    tipobj.style.width=''
    }
    }
    
    document.onmousemove=positiontip
    
    </script>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    tmate (08-06-2014)

Similar Threads

  1. Onclick multiple actions?
    By harlem in forum JavaScript
    Replies: 2
    Last Post: 01-22-2010, 10:49 AM
  2. ToolTip - Multiple Actions?
    By wildpeacockstudios in forum Dynamic Drive scripts help
    Replies: 7
    Last Post: 05-12-2008, 03:48 PM
  3. Replies: 7
    Last Post: 05-12-2006, 07:18 PM
  4. Multiple actions from single 'onclick'?
    By Hebbs in forum JavaScript
    Replies: 7
    Last Post: 06-23-2005, 01:59 PM

Bookmarks

Posting Permissions

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