I am trying to open an image in a new tab when user clicks on the thumbnail, but even though I've tried many different solutions none of them worked.
I am posting jquery code:
$('#imagelink').click(function() {
//location.href = $('#imagelink').attr("href"); //It is correct!
// window.location.href = this.id + '.html'; //It is correct!
// window.open($('#imagelink').attr("href"), '_blank');
// $.winOpen($('#imagelink').attr("href"), "windowName", { fullscreen: "no", height: "600px", toolbar: 1, width: 600 }); //It is correct!
window.location = $.myURL("index", $(this).attr("href"));//It is correct!
});
As you can see I've tried all of the above five aspects and all of them open the image in the same tab which is not what I desire.
I am posting also the jquery code that includes also the html (this is included in separate file):
new_span.append('<a id="imagelink" href="'+ new.link +'"><img src="' + new.url +'" height=50px width="50px" /></a>');
Any kind of help is appreciated.
Try with target
as _blank
like
new_span.append('<a id="imagelink" href="'+ new.link +'" target="_blank"><img src="' + new.url +'" height=50px width="50px" /></a>');
Or you can also try with javascript
using window.open
like
$('#imagelink').click(function() {
var URL = $.myURL("index", $(this).attr("href"));
window.open(URL,'_blank','','');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With