Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问firefox插件中的html文件_Html_Firefox Addon_Firefox Addon Sdk - Fatal编程技术网

访问firefox插件中的html文件

访问firefox插件中的html文件,html,firefox-addon,firefox-addon-sdk,Html,Firefox Addon,Firefox Addon Sdk,我正在开发一个插件,它在点击一个带有特殊html的按钮时会打开一个新选项卡。现在,html文件在一个专用的Web空间中,但是是否有一个解决方法,也就是说,我可以将html文件放在插件本身的数据结构中并从那里访问它吗?问题是,当点击按钮连接到url时,我传递了活动站点的url,我在html中使用AngularJS,这似乎是个问题 我的代码: index.js: var { ActionButton } = require("sdk/ui/button/action"); var tabs = re

我正在开发一个插件,它在点击一个带有特殊html的按钮时会打开一个新选项卡。现在,html文件在一个专用的Web空间中,但是是否有一个解决方法,也就是说,我可以将html文件放在插件本身的数据结构中并从那里访问它吗?问题是,当点击按钮连接到url时,我传递了活动站点的url,我在html中使用AngularJS,这似乎是个问题

我的代码:

index.js:

var { ActionButton } = require("sdk/ui/button/action");
var tabs = require("sdk/tabs");
var data = require("sdk/self").data; 

var button = ActionButton({
  id: "my-button",
  label: "Start LLIBrowser",
  icon: {
    "16": "./img/logo-16.png"
  },
  onClick: showPlugIn
});

function showPlugIn(state){ 
  let currUrl = tabs.activeTab.url;
  //var file = "file:///home/janine/OneDrive/Uni/OvGU/4. Semester/SoftwareProjekt/LLIBrowserGalleryAndInfo/data/overlay.html"; just for testing
  var file = "http://www-e.uni-magdeburg.de/jpolster/LLIBrowser/overlay.html";
  var completePath = file.concat("?url=").concat(currUrl);

  tabs.open(completePath)
}
有什么想法吗


干杯

理论上,我看不出有什么问题。 将HTML文件放在数据文件夹中,并通过以下方式访问:

var file = data.url("overlay.html");
编辑:M.Onyshchuk说这将触发

地址无效

错误。我没有想到“:”。为了解决这个问题,只需从URL中删除协议信息

    currUrl = currUrl.replace(/^https?\:\/\//i, "");
要在您的插件中仍然使用AngularJS,最简单的方法是将当前版本与您的插件一起发布。下载最新版本,将其放在数据文件夹中,然后以通常的方式在HTML文件中访问它

虽然我不熟悉AngularJS,但我想不出任何理由说明这不起作用

祝你的项目好运


理论上,我看不出有什么问题。 将HTML文件放在数据文件夹中,并通过以下方式访问:

var file = data.url("overlay.html");
编辑:M.Onyshchuk说这将触发

地址无效

错误。我没有想到“:”。为了解决这个问题,只需从URL中删除协议信息

    currUrl = currUrl.replace(/^https?\:\/\//i, "");
要在您的插件中仍然使用AngularJS,最简单的方法是将当前版本与您的插件一起发布。下载最新版本,将其放在数据文件夹中,然后以通常的方式在HTML文件中访问它

虽然我不熟悉AngularJS,但我想不出任何理由说明这不起作用

祝你的项目好运


因此,仅更改文件加载URI是不够的:

  var file = data.url("overlay.html");
在这种情况下,您将看到如下错误:

地址无效

但您可以修改代码并发送当前选项卡url,而不是作为URI的查询部分,而是作为片段部分:

  let currUrl = tabs.activeTab.url;
  currUrl = currUrl.replace(":", "%");
  var file = data.url("overlay.html");
  var completePath = file.concat("#").concat(currUrl);
不幸的是,encodeURIComponent不起作用:

  let currUrl = encodeURIComponent(tabs.activeTab.url); // The address isn't valid

您需要在overlay.html中解析片段URI(在#之后)

仅更改文件加载URI是不够的:

  var file = data.url("overlay.html");
在这种情况下,您将看到如下错误:

地址无效

但您可以修改代码并发送当前选项卡url,而不是作为URI的查询部分,而是作为片段部分:

  let currUrl = tabs.activeTab.url;
  currUrl = currUrl.replace(":", "%");
  var file = data.url("overlay.html");
  var completePath = file.concat("#").concat(currUrl);
不幸的是,encodeURIComponent不起作用:

  let currUrl = encodeURIComponent(tabs.activeTab.url); // The address isn't valid
您需要在overlay.html中解析片段URI(在#之后)