javascript - How to open different link in new tab with different popup buttons -
i'm using button open ajax html popup , link onclick @ same time. problem have several buttons placed on page , each button want open different links appreciated
heres html code
<a href="test.html" class="ajax-popup-link"> <button type="button" style="background:green;float:right;"> activate </button> </a>
heres javascript function
<script src="../assets/jquery.magnific-popup.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.ajax-popup-link').magnificpopup({ type: 'ajax', overflowy: 'scroll', closeoncontentclick: false }); $('.ajax-popup-link').click(function(){ window.open("/some-link.html"); }); });</script>
in click
function, reference href
attribute instead of hard coding link. idea prevent browser's default behaviour on link click:
$('.ajax-popup-link').click(function(e){ e.preventdefault(); window.open($(this).attr("href")); });
Comments
Post a Comment