获取页面选择,包括HTML? [英] Get page selection including HTML?

查看:93
本文介绍了获取页面选择,包括HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在撰写Chrome扩展程序,并且想知道是否可以获取特定标签的选定文本,包括底层HTML?因此,如果我选择一个链接,它也应该返回< a> 标记。



上下文菜单事件对象(是的,我为此使用上下文菜单),这就是回调所带来的一切:

  editable:false 
menuItemId:1
pageUrl:< the URL>
selectionText:<纯文本格式的选定文本,不是HTML>

它也会返回一个Tab对象,但是其中没有任何内容非常有用。



所以我在这里有点不知所措。这甚至有可能吗?如果是这样,你可能有任何想法都会很棒。谢谢! :

rel =nofollow noreferrer>这个和扩展程序做你的需要。


I'm writing a Chrome Extension, and I was wondering if it was possible to get the selected text of a particular tab, including the underlying HTML? So if I select a link, it should also return the <a> tag.

I tried looking at the context menu event objects (yes, I'm using a context menu for this), and this is all that comes with the callback:

editable : false
menuItemId : 1
pageUrl : <the URL>
selectionText : <the selected text in plaintext formatting, not HTML>

It also returns a Tab object, but nothing in there was very useful, either.

So I'm kind of at a loss here. Is this even possible? If so, any ideas you might have would be great. Thanks! :)

解决方案

Looks like this and this extensions do what you need.

这篇关于获取页面选择,包括HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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