call back function set by JS settimeout doesn't work in IE8....
        Posted  
        
            by NAG
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by NAG
        
        
        
        Published on 2010-06-02T10:13:50Z
        Indexed on 
            2010/06/03
            5:14 UTC
        
        
        Read the original article
        Hit count: 276
        
js
<html>  
 <head>  
 <script>  
 function addEvent( obj, type, fn ) {  
   if ( obj.attachEvent ) {  
     obj['e'+type+fn] = fn;  
     obj[type+fn] = function(){obj['e'+type+fn]( window.event );}  
     obj.attachEvent( 'on'+type, obj[type+fn] );  
   } else 
     obj.addEventListener( type, fn, false );  
 }  
 </script>  
 </head>  
 <body>  
 <!-- HTML for example event goes here -->  
 <div id="mydiv" style="border: 1px solid black; width: 100px; height: 100px; margin-top: 10px;"></div>  
 <script>  
 // Script for example event goes here  
 addEvent(document.getElementById('mydiv'), 'contextmenu', function(event) {  
     display_short('right-clicked (contextmenu)');  
 });  
 function display_short(str)  
 {  
     clearTimeout();  
     document.getElementById('mydiv').innerHTML = str;  
     if (str != '')  
         alert("hello");
         setTimeout("display_short('abcd')", 1000);  
 }  
 </script>  
 </body>  
 </html> 
Behaves diffrently in IE and FF when you right click on the div area. In ff display_short will be called for evry 1 sec eventhough you dont release right click but in IE it will not call display_short if you dont release right click.
But i expect in IE it should call display_short for every 1 sec if you dont release also. Is there any solution for this?
© Stack Overflow or respective owner