javascript - 从网页中选择复制将页面超链接添加到剪贴板

标签 javascript html

如果您从例如 http://www.wired.com/gadgetlab/2010/01/ipad-flash/ 中选择一个段落并将其粘贴到word中,您会注意到该页面的链接已添加到该段的末尾。

这是一个例子:

Some of Apple’s promotional material about the iPad implies the device’s Safari browser can load Adobe Flash content. However, demonstration units of the tablet, including the one presented by Steve Jobs, could not, and a consumer has already filed a complaint to the Federal Trade Commission alleging false advertising.

Read More http://www.wired.com/gadgetlab/2010/01/ipad-flash/#ixzz0f2nM0huW

他们是怎么做到的???

他们还在链接末尾添加#ixzz0f2nM0huW,当您关注页面时,所选文本会突出显示!

是否有一个 javascript 库可以做到这一点?

最佳答案

他们使用 Tynt Insight .它是一个带有 free version 的商业 JavaScript 库。其中包括您问题中描述的“归因链接”功能。

您可以在 <head> 中的 HTML 中看到它被引用标签:

<!-- Tynt Tracer> --> 
<script type="text/javascript"> tyntVariables = {"ap":"Read More"}; </script> 
<script type="text/javascript" src="http://tcr.tynt.com/javascripts/Tracer.js?user=ac4i_23GOr3QjHab7jrHcU&s=112"></script> 

正如 Tim Down 在上面的评论中指出的那样,Anirvan gave a very good briefing on the internals of the Tynt script ,在单独的 Stack Overflow 帖子中。

关于javascript - 从网页中选择复制将页面超链接添加到剪贴板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2229249/

相关文章:

html - 在 rails 中 Bootstrap ——没有 bootstrap.css

javascript - node.js 博客应用程序教程

javascript - 使用 HTML、CSS 和 JS 构造一个 "3D"的建筑

html - 给带有无法清除的 float 元素的元素设置高度

html - 当文本很长时,如何在 flex 显示中对文本进行分词?

javascript - HTML5 Canvas 随着时间的推移而抖动

javascript - 事件代码在不同浏览器中的行为不同

javascript - 如何将 HTML youtube 视频向右移动/过渡

javascript - 将 openCV C++ 视频流式传输到浏览器

javascript - 在 AngularJS html 模板中使用与号 (&) 是否安全