Jquery: Open link in new window. Re-usable with custom dimensions per link -
in situations open links in new windows jquery. wondering how keep common code links, while modifying width , height per link?
(the width/height width/height of window opens when link clicked).
i thinking of using custom data attribute (like: data-window-width , data-window-height).
i have made start not sure of how handle width , height variables.
html:
<a href="some_link_here" class="linksocial" data-window-width="700" data-window-height="400">link text</a>
javascript:
//open social links in new window $('body').on('click', 'a.linksocial', function() { var width = 'width' + $(this).data('window-width'); var height = 'height' + $(this).data('window-height'); //not sure next width , height! newwindow=window.open($(this).attr('href'),'','height=400,width=770'); if (window.focus) {newwindow.focus()} return false; });
Comments
Post a Comment