html/javascript: Hiding link destination and opening link in new tab -
i using following javascript (provided m59 in this previous answer) hide destination of link shows @ bottom of browser window when hovering on link:
<div> <a data-href="http://www.google.com/"> link </a> <script type="text/javascript"> var anchors = document.queryselectorall('a[data-href]'); (var i=0; i<anchors.length; ++i) { var anchor = anchors[i]; var href = anchor.getattribute('data-href'); anchor.addeventlistener('click', function() { window.location = href; }); } </script> </div>
this works fine, link open in new tab well. how have change script in order so?
i tried using window.open('href','_blank');
instead of window.location = href;
did not work.
unless im missing something, obvious thing add target anchor:
<a data-href="http://www.google.com/" target="blank"> link </a>
Comments
Post a Comment