Reputation: 125
I have added a image via js and can't seem to figure out how to add a link as well as target="_blank" to that image... here the code I am working with:
$(function() {
$('body').delegate('.post-type-icon', 'click', function(){
var url = $(this).parents('.post-content').attr('data-url');
var newwindow = window.open('http://instagram.com?_url='+encodeURIComponent(url),'windowname','height=350,width=500');
});
});
Right now with this code when you click on the icon doesn't open to the link... not sure what I am doing wrong and any help would be greatly appreciated. Thanks!
Upvotes: 0
Views: 877
Reputation: 1062
window.open is used for opening popup windows, try this:
<a href='/someurl' target='_blank'>
<div id='yourimage'></div>
</a>
This way if they click on your image, its contained in an anchor tag and will cause a window to be opened in a new tab.
Upvotes: 2