安装插件后,在Firefox中打开我的页面 [英] Opening my page in firefox after installing the addon

查看:147
本文介绍了安装插件后,在Firefox中打开我的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述








$ b

为此,我在加载页面上添加了事件处理程序,并且首次检查了这个事件的执行地点。

  window.addEventListener(load,initializeOverlay,false); 

但是我的问题是如何在firefox开始时在新标签页中打开页面。我使用

 `window.open(https://www.xyz.com/);`

但在新窗口打开页面甚至可能在Internet Explorer中打开。



那么有没有什么办法可以在同一个窗口打开新标签中打开页面。



感谢
BHAVIK GOYAL

解决方案

我设法使用偏好来做类似的事情,而不是创建文件等。

在/defaults/preferences/default.js中:

  pref(extensions.extension_name.just_installed ,是); 
pref(extensions.extension_name.post_install_url,http://www.google.com);



然后在主JS文件中加入:

  //检索首选项。 
var prefs;
prefs = Components.classes [@ mozilla.org/preferences-service;1\"].getService(Components.interfaces.nsIPrefService).getBranch(\"extensions.extension_name。);
prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);

//如果刚刚安装,请打开安装后页面并更新首选项。
var just_installed = prefs.getBoolPref(just_installed);
var post_install_url = prefs.getCharPref(post_install_url);
if(just_installed){
prefs.setBoolPref(just_installed,false);
gBrowser.selectedTab = gBrowser.addTab(prefs.getCharPref(post_install_url));



$ b $ p
$ b

唯一的问题是,Firefox不会重置由扩展程序保存的首选项扩展名已被卸载。


HI,

My am trying to open my home page after the firefox restarts for the first time after installation.

For this i am adding the event handler on load page and checks where this event is executed for the first time or not.

window.addEventListener("load", initializeOverlay, false);

But my problem is how to open the page in new tab when the firefox get started. I use

`window.open("https://www.xyz.com/");`

but that opens the page in new window that might even be open in internet explorer.

So is there any way to open the page in new tab in same window which is going to be open.

Thanks BHAVIK GOYAL

解决方案

I manage to do something similar using preferences, rather than creating files, etc.

Inside of /defaults/preferences/default.js:

pref("extensions.extension_name.just_installed", true);
pref("extensions.extension_name.post_install_url", "http://www.google.com");

Then inside the main JS file for the add-on:

// Retrieve the preferences.
var prefs;
prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.extension_name.");
prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);

// If we just installed, open the post-install page and update the preferences.
var just_installed = prefs.getBoolPref("just_installed");
var post_install_url = prefs.getCharPref("post_install_url");
if (just_installed) {
  prefs.setBoolPref("just_installed", false);
  gBrowser.selectedTab = gBrowser.addTab(prefs.getCharPref("post_install_url"));    
}

Only problem is Firefox doesn't reset the preferences saved by an extension after that extension is uninstalled.

这篇关于安装插件后,在Firefox中打开我的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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