JQuery-单击图像打开单独的窗口

JQuery-单击图像打开单独的窗口,jquery,onclick,Jquery,Onclick,当用户单击缩略图时,我试图在新选项卡中打开图像,但尽管我尝试了许多不同的解决方案,但没有一个有效 我发布jquery代码: $('#imagelink').click(function() { //location.href = $('#imagelink').attr("href"); //It is correct! // window.location.href = this.id + '.html'; //It is correct! // window.ope

当用户单击缩略图时,我试图在新选项卡中打开图像,但尽管我尝试了许多不同的解决方案,但没有一个有效

我发布jquery代码:

$('#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!

    });
正如你所看到的,我已经尝试了以上五个方面,所有这些都在同一个选项卡中打开了图像,这不是我想要的

我还发布了jquery代码,其中还包括html(这包含在单独的文件中):

new_span.append(“”);

感谢您提供的任何帮助。

尝试将
目标设置为
\u blank
类似

new_span.append('<a id="imagelink" href="'+ new.link +'" target="_blank"><img src="' + new.url +'" height=50px width="50px"  /></a>');
$('#imagelink').click(function() {
    var URL = $.myURL("index", $(this).attr("href"));
    window.open(URL,'_blank','',''); 
});
使用:

标签中

如果要遵循jquery,请使用:

$('#imagelink').click(function() {
     var loc = $(this).attr("href");
     window.open(loc, '_blank');
});

只需在HTML的标题部分添加以下内容

<base target='_blank' />
这里#我的内容是你链接所在部分的id。
这是针对锚定标签的,但也适用于图像。

根据您的问题,您只需要

target='_blank' //attribute for anchor tag.
new_span.append('<a id="imagelink" href="'+ new.link +'" target="_blank"><img src="' + new.url +'" height=50px width="50px"  /></a>');

哇!这对你来说只是小菜一碟!!成功了!我是个新手,但我正在努力维护和扩展另一个人的项目。多谢各位!我不知道我是否应该提出一个新问题。但我也试着用hover来做。我的意思是当鼠标悬停在缩略图上以查看实际的图像页面时。实际上,这是最初的要求,但我发现从单击事件开始更容易。你能帮我吗?提前谢谢。谢谢@srikanthbattula!我还有一个问题,如果我想在缩略图上悬停以获得具有图像实际大小的帧,我应该如何做?你能帮忙吗?
<base target='_blank' />
$('#my-Content a[href^="http://"]').attr("target", "_blank");
target='_blank' //attribute for anchor tag.
new_span.append('<a id="imagelink" href="'+ new.link +'" target="_blank"><img src="' + new.url +'" height=50px width="50px"  /></a>');
_blank  Load in a new window
_self   Load in the same frame as it was clicked
_parent Load in the parent frameset
_top    Load in the full body of the window