本文介绍了Javascript:劫持副本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在线阅读泰晤士报,我想从文章中复制一些文字并将其发送给朋友,但我注意到,当我这样做时,它会自动将链接添加回我所拥有的文章中复制。

I was just reading the Times online and I wanted to copy a bit of text from the article and IM it to a friend, but I noticed when I did so, it automatically appended the link back to the article in what I had copied.

这不是我的IM客户端的功能,所以我认为这是因为时代网站上的一些javascript发生的。

This is not a feature of my IM client, so I assume this happened because of some javascript on Times website.

如果我想在我的网站上实现它,我将如何实现这一目标?基本上,我必须劫持复制操作并将文章的URL附加到复制内容的末尾,对吧?想法?

How would I accomplish this if I wanted to implement it on my site? Basically, I would have to hijack the copy operation and append the URL of the article to the end of the copied content, right? Thoughts?

以下是我正在阅读的文章,供参考:

Here's the article I was reading, for reference: http://www.time.com/time/health/article/0,8599,1914857,00.html

推荐答案

使用jQuery(您引用的网站正在使用)是轻而易举的:

It's a breeze with jQuery (which your referenced site is using):

$("body").bind('copy', function(e) {
    // The user is copying something
});

您可以使用jQuery Search&共享插件,只要有人从您的网站复制超过40个字符,就会执行完全事情:

You can use the jQuery Search & Share Plugin which does this exact thing whenever somebody copies more than 40 chars from your site: http://www.latentmotion.com/search-and-share/

您引用的网站显然正在使用名为可以实现此目的。

The site that you referenced is apparently using a service called Tynt Insight to accomplish this though.

这篇关于Javascript:劫持副本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 13:47