【发布时间】:2012-12-25 17:10:21
【问题描述】:
我正在使用 JavaScript 为 Chrome 浏览器编写 Gmail 扩展程序。
我正在尝试使用此代码从Compose 页面获取send 按钮元素:
SendButton = document.getElementById('js_frame').contentDocument.getElementsByClassName('T-I J-J5-Ji Bq nS T-I-KE L3')[0];
但后来我不断收到一条消息说typeof SendButton is undefined。
我该如何解决这个问题?
【问题讨论】:
-
试试
contentWindow.document而不是contentDocument。 -
不幸的是 - 不工作......
-
@Teemu
frameElement.contentWindow是内容脚本中的undefined。此外,所有现代浏览器(和 IE8+)都支持contentDocument属性。 -
@RobW 感谢您的信息,我想我也可以学会使用
contentDocument:)。
标签: javascript google-chrome google-chrome-extension gmail