如何限制链接在新标签页中只打开一次? [英] How to limit the link open only once in new tab?

查看:30
本文介绍了如何限制链接在新标签页中只打开一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,单击链接后,我在新选项卡中打开一个 pdf 文件,但是如果该文件已打开,则在第二次单击后,而不是在新选项卡中打开,我想重定向到该文件的打开选项卡.

In my code, after click on a link I'm open a pdf file in new tab, But after second click if that file is already open then instead of open in new tab I want to redirect to open tab of that file.

我的代码:

<span style="margin-left:10%;"><a href="image/Eng_Pamphlet.pdf" target="_blank">Broucher</a></span>'

如上面的选项卡所示,我设置了目标属性_blank",因此它始终在新选项卡中打开链接.但我想在第一次之后重定向到第一个打开的标签.

As shown in above tab I'm set the target attribute "_blank", So it opens the link always in new tab. But I want after first time it redirect to first open tab only.

推荐答案

改用 target="_new".这将在同一选项卡中打开链接

Use target="_new" instead. This will open the link in the same tab

_new 并不是真正做到这一点的最佳方式,正如 Chankey 在下面的评论中所指出的那样.您可以为 target 属性创建一个自定义"值,该值将允许链接仅在特定选项卡中打开.

_new is not really the best way to do this, as noted in the comment below by Chankey. You can just create a 'custom' value for the target attribute that will allow the link to only open in a specific tab.

http://jsfiddle.net/GTr7L/ -> 示例

这篇关于如何限制链接在新标签页中只打开一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆