是否可以检测用户是否在新标签中打开了链接? [英] Is it possible to detect if a user has opened a link in a new tab?

查看:116
本文介绍了是否可以检测用户是否在新标签中打开了链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户在您的网站上并在新标签页中打开了另一个链接(也是您的网站),是否可以将其与用户区别开来?这可以是javascript,在服务器上,无论如何。

If a user is on your website and opens another link (also to your website) in a new tab, is it possible to differentiate this from the user just clicking on the link normally? This can be in javascript, on the server, whatever.

我猜答案是你不能这样做,但我想仔细检查。

I'm guessing that the answer is that you cannot do this, but I wanted to double check.

推荐答案

你可以这样做:

if (history.length == 1) {  // Um, needs to be 0 for IE, 1 for Firefox
    // This is a new window or a new tab.
}

history.length <可能还有其他方式/ code>要 1 ,但我不知道它们可能是什么。

There may be other ways for history.length to be 1, but I don't know what they might be.

这篇关于是否可以检测用户是否在新标签中打开了链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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