Skip to content

Instantly share code, notes, and snippets.

@imitronov
Last active February 4, 2019 07:26
Show Gist options
  • Save imitronov/b309aa41b541a33ecb9d21b6b6449314 to your computer and use it in GitHub Desktop.
Save imitronov/b309aa41b541a33ecb9d21b6b6449314 to your computer and use it in GitHub Desktop.
open share links to new window
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Share demo</title>
</head>
<body>
<a data-share href="https://www.facebook.com/sharer.php?src=sp&u=http://github.com">FACEBOOK</a>
</body>
</html>
$(function(){
var shareLinks = $('[data-share]');
$.each(shareLinks, function(i,e){
var href = $(this).attr('href');
console.log(href);
$(e).on('click', function(e){
e.preventDefault();
var href = $(this).attr('href');
var xsize = 680;
var ysize = 600;
var left = ($(window).width() - xsize) / 2;
var top = ($(window).height() - ysize) / 2;
window.open(href, '', 'Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0,Scrollbars=1,Resizable=1,Width=' + xsize + ',Height=' + ysize + ',Left=' + left + ',Top=' + top);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment