:::: MENU ::::
Posts tagged with: javascript

How to detect left mouse click and right mouse click with jQuery

If you want to implement a javascript interface probably you will get to a point where you have to know witch button was pressed. The next code will detect correctly for IE, Firefox, Chrome, Opera and Safari.


/* this will append click detection to whole document
 * if you want to add this feature just on one area
 * just change the selector for the jQuery
 */
jQuery(document).click(function(event) {
   if (jQuery.browser.msie){
      if (event.which < 2){
         alert('Left button');
      }
   }else
   switch (event.which) {
      case 1:
         alert('Left button');
         break;
      case 2:
         alert('Middle button');
         break;
      case 3:
         alert('Right button');
         break;
      default:
         alert('unknown');
   }

});

Continue Reading


How to open new window with window.open and not be seen by chrome a popup

If in the command stack the window.open is not direct under the onClick event then the new window it must be a popup. If the browser is set to block popups the new window will be blocked.

Now in the WEB 2.0 world where ajax calls are a must opening a window after a success ajax call will be seen as a popup Window and Chrome will block this. Continue Reading