Skip to content

Instantly share code, notes, and snippets.

@mcbrwr
Last active May 31, 2016 14:05
Show Gist options
  • Save mcbrwr/529b7b4b0128c16c43dc to your computer and use it in GitHub Desktop.
Save mcbrwr/529b7b4b0128c16c43dc to your computer and use it in GitHub Desktop.
vanilla JS to open href of a link in popup window (ie for custom share buttons)
@mcbrwr
Copy link
Author

mcbrwr commented Jan 19, 2015

    var elements = document.querySelectorAll('.socialshares a');
    Array.prototype.forEach.call(elements, function(el, i){
      el.onclick = function(elaction) {
        elaction.preventDefault();
        window.open( el.attributes.href.value, '', 'width=600,height=300' );
      }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment