【问题标题】:Access DOM using browser object in javascript在 javascript 中使用浏览器对象访问 DOM
【发布时间】:2012-07-28 16:14:45
【问题描述】:

我正在用 javascript 编写一个 firefox 扩展,从该脚本中我需要使用浏览器窗口对象访问 DOM 对象。我如何实现这一目标?

当我在扩展程序中尝试 window.document.deafultView.innerHeight 时,我遇到了异常。

我不知道如何使用插件中的窗口对象访问 DOM 对象。

【问题讨论】:

  • 你在写什么样的扩展/插件?它是浏览器扩展吗?用什么浏览器?
  • @PascalBeyeler 这个问题有 2 个标签 - firefoxfirefox addon

标签: javascript firefox firefox-addon


【解决方案1】:

根据http://semanticvoid.com/blog/2006/06/01/accessing-the-dom-from-within-the-firefox-extension/,您可以通过以下方式访问 DOM:

// Get the content of the currently displaying window
var win = window.content;

// Access the document within the window as follows
win.document.getElementById(‘xyz’);

【讨论】:

    猜你喜欢
    • 2011-06-28
    • 1970-01-01
    • 2010-11-05
    • 1970-01-01
    • 2010-09-13
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 2015-03-19
    相关资源
    最近更新 更多