【问题标题】:IncludeCSS not working on IEIncludeCSS 在 IE 上不起作用
【发布时间】:2016-03-26 19:34:20
【问题描述】:

我想在我的扩展程序上创建一个 browserAction,当我点击 browserAction 的图标时打开一个选项页面(类似于我们在 chrome 中可以做的)。我创建了代码来执行我所描述的操作,当我单击 FF 上的图标时,一切正常,页面样式看起来也不错。相反,在 IE11 上,当我单击图标时,页面显示为没有任何样式。

我上传到我的资源,我需要的所有文件,我的 options.html、css/style.css 和我的图像。这是我的代码...

而我的background.js 看起来像这样:

appAPI.ready(function($) {

  // Sets the initial browser icon
  appAPI.browserAction.setResourceIcon('48x48.png');

  // Sets the tooltip for the button
  appAPI.browserAction.setTitle('My title');

  // Sets the initial onClick event handler for the button
  appAPI.browserAction.onClick(function(){
  appAPI.openURL({
                resourcePath: "options.html",
                where: "tab",
                focus: true
            });
  });
});

和我的extension.js 是这样的:

if (document.title == "My options page title") {
  appAPI.resources.includeCSS('css/style.css');
}

上面的代码,根据标题检查它是否是我想要的页面(这不是一个好方法,我知道,但我现在正在测试......如果你对此有一些建议,我将不胜感激也)

我做错了什么?

@Crossrider 支持:我的应用 id 是 81180

感谢您的帮助

【问题讨论】:

  • 您检查了document.title 的值并确定if 语句有效吗?
  • 是的!我检查了它,即使我删除了 if 语句......它也不起作用

标签: javascript internet-explorer-11 browser-extension crossrider


【解决方案1】:

options.html 页面在独立的上下文中运行(即 extension.js 不能保证在所有浏览器上运行),因此您应该在 HTML 页面中嵌入 CSS。

[披露:我是 Crossrider 的员工]

【讨论】:

    猜你喜欢
    • 2013-08-19
    • 2023-04-04
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-07
    相关资源
    最近更新 更多