Forum Replies Created

Viewing 1 replies (of 1 total)
  • I doubt this is appropriate here considering the button code provided by Pinterest doesn’t open in a popup, regardless, made a slight improvement to your code for my own uses, slightly more efficient selector (no need to wrap in div), closure, and popup opens in center of window.

    $('.pin-it-button').click(function (e) {
      (function (url, title, w, h) {
        var left = (screen.width/2)-(w/2);
        var top = (screen.height/2)-(h/2);
        return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
      })($(this).attr('href'), 'Pinterest', 600, 280);
    
      e.preventDefault();
    });

    Also note: Don’t use return false to preventDefault action, that will also prevent event bubbling in jQuery and could potentially break other things.

Viewing 1 replies (of 1 total)