当用户点击缩略图时,我试图在新选项卡中打开图像,但即使我尝试了许多不同的解决方案,但它们都没有奏效.
我发布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!
});
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我已经尝试了以上五个方面的所有方面,所有这些都在同一个标签中打开图像,这不是我想要的.
我也发布了包含html的jquery代码(这包含在单独的文件中):
new_span.append('<a id="imagelink" href="'+ new.link +'"><img src="' + new.url +'" height=50px width="50px" /></a>');
Run Code Online (Sandbox Code Playgroud)
任何形式的帮助表示赞赏.
与尝试target为_blank像
new_span.append('<a id="imagelink" href="'+ new.link +'" target="_blank"><img src="' + new.url +'" height=50px width="50px" /></a>');
Run Code Online (Sandbox Code Playgroud)
或者你也可以尝试javascript使用window.open喜欢
$('#imagelink').click(function() {
var URL = $.myURL("index", $(this).attr("href"));
window.open(URL,'_blank','','');
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15917 次 |
| 最近记录: |