I've got a button like so:
<button class="facebook text-white" href='http://www.facebook.com/sharer.php?u=url.com'>
<img src="{{ asset('assets/img/facebook.png') }}">
<span>{{"share" | trans}}</span>
</button>
I've got a js file named social.js with the following contents:
$(document).ready(function(){
$(".twitter").click(function(e) {
e.preventDefault();
var href = $(e.target).attr('href');
window.open(href, "Share your stats on Twitter!", "height=300,width=550")
});
$(".facebook").click(function(e) {
e.preventDefault();
var href = $(e.target).attr('href');
window.open(href, "Share you stats on Facebook!", "height=300,width=550")
});
});
This results in weird behaviour, as sometimes the designated link does load and opens, and sometimes it just stays on about:blank.
After every click it seems totally random if it opens up the link or not.
How do I fix this flaky behaviour?