我可以访问作为Google Chrome扩展程序一部分的JavaScript中的iframe内容吗? [英] Can I access the content of an iframe in JavaScript that is part of a Google Chrome extension?

查看:128
本文介绍了我可以访问作为Google Chrome扩展程序一部分的JavaScript中的iframe内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在名为test_iframe的主窗口中有一个iframe。我想在 Google Chrome 扩展程序中访问test_iframe的内容。我明白如果我在 manifest.json 中给出了必要的权限,我可以这样做。



我可以访问这个iframe从背景HTML页面的内容?或者我可以在作为该扩展程序的一部分的内容脚本中访问它吗? (在后一种情况下,我想我必须将iframe内容从内容脚本传递到后台页面作为进一步处理(?)的消息的一部分)

解决方案

假设这个 test_iframe 来自 http://frame.example.com 。我只是将一个内容脚本直接注入到 frame.example.com (而不是父页面),并在那里做所有事情。


I have an iframe within the main window named "test_iframe". I want to access the content of "test_iframe" within a Google Chrome extension. I understand that I can do this if I have requisite permissions given in manifest.json.

Can I access the content of this iframe from a background HTML page? Or can I access it in a content script which is part of that extension? (In the latter case I suppose I have to pass the iframe content from the content script to a background page as part of a message for further processing(?))

解决方案

Let's say this test_iframe comes from http://frame.example.com. I would just inject a content script directly to frame.example.com (instead of the parent page) and do everything there.

这篇关于我可以访问作为Google Chrome扩展程序一部分的JavaScript中的iframe内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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