SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict ruba's Avatar
    Join Date
    Apr 2005
    Location
    Amman -Jordan
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question alert when hold the mouse on image for 3 sec

    Hi all
    I want to show alert when the user put the moure on Image for 3 sec. is it possible ?
    Open Blocked website
    Open Blocked Website
    Knowledge Is Knowing That A Tomato Is A Fruit,
    Wisdom Is Not Putting It In A Fruit Salad.

  2. #2
    SitePoint Zealot the DtTvB's Avatar
    Join Date
    Jul 2006
    Location
    Thailand
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <img id="test" src="yay.jpg" alt="Yay!" />
    
    <script type="text/javascript">
    
    function addEvent(el, evt, fnc) {
    	if (el.addEventListener)
    		return el.addEventListener(evt, fnc, false); 
    	else if (el.attachEvent)
    		return el.attachEvent('on' + evt, fnc);
    	return false;
    }
    
    function alertOnHover(element, time, txt) {
    	var tmr = 0;
    	function showAlert() {
    		alert (txt);
    	}
    	addEvent (element, 'mouseover', function() {
    		tmr = setTimeout(showAlert, time);
    	});
    	addEvent (element, 'mouseout', function() {
    		clearTimeout (tmr);
    	});
    }
    
    alertOnHover (document.getElementById('test'), 3000, 'Move that mouse pointer away!');
    
    </script>

  3. #3
    SitePoint Addict ruba's Avatar
    Join Date
    Apr 2005
    Location
    Amman -Jordan
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thaaaaaaaaaaaaank u alot
    Open Blocked website
    Open Blocked Website
    Knowledge Is Knowing That A Tomato Is A Fruit,
    Wisdom Is Not Putting It In A Fruit Salad.


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
  •