javascript - 如何从 chrome contentscript 获取页面中富文本编辑器生成的 iframe 中选中的文本
迷茫
迷茫 2017-04-10 13:11:42
[JavaScript讨论组]

我想在 Chrome 扩展中获取页面中富文本编辑器生成的 iframe 中选中的文本,我尝试了两种方法,但都失败了。

1. 在定义 contentscript 时指定 "all_frame": true

contentscript 无法被注入到动态生成并且没有指定 src 的 iframe 中,所以脚本根本不会在富文本编辑器的 iframe 中执行。

2. 遍历页面中所有的 iframe,找出 document.bodycontenteditable="true" 的那个,然后获取里面的选中文本

因为 origin 和 protocol 不同,导致对该 iframe 没有访问权限。

Blocked a frame with origin "https://www.evernote.com" from accessing a frame with origin "chrome-extension://oknpjjbmpnndlpmnhmekjpocelpnlfdi". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "chrome-extension". Protocols must match.


求教各位,有没有什么好的办法。

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号