Thursday 15 January 2015

Firefox Addon Button Code Not Working - Javascript -


I am creating a Firefox extension which is designed to automatically design a button on the toolbar When clicked, a web page will open in a new tab. I have used the code snippet from the Mozilla Dev site, but when both are put together, the button placement works nothing but clicking the button.

I do not know much about Javascript, so I do not know what's going wrong here. The entire extension did not pass all Mozilla verification checks with all the errors and warnings.

Here is the code. Any help you can provide will be appreciated.

  CustomButton = {1: function installButton (toolbar id, id, afterId) {if (! Document.getElementById (id)) {var toolbar = document .getElementById (toolbarId); // If no later ID is given, then add the item to the toolbar = faucet; If (afterId) {command = document. GetElementById (afterId); If (elem & elem.parentNode == toolbar) = elem.nextElement before sibling; } Toolbar.insertItem (id, first); Toolbar.setAttribute ("currentset", toolbar.startSet); Document.persist (toolbar.id, "currentset"); } If (formerly) {installButton ("nav-bar", "my extension-navbar-button"); }}, 2: function () {const url = "http://www.mysite.com/" document .getElementById ("content") .webNavigation .loadURI (url, 0, null, null, null)}} < / Code>  

I am not very sharp on this, that is why I am asking questions instead of searching for other examples, which I do not understand. If someone can show me what I want to do to do this, then I would be grateful to modify this specific code.

It will work with FF29, which will be released in April 2014. This adds an action-button to the toolbar, once you click it, it will load the site in a new tab; If you prefer to load a new window then instead ("sdk / windows") is required.

use of addon-sdk

  var ui = ("sdk / ui"); Var action_button = ui.ActionButton ({id: "my-button", label: "Open an example page!", Icon: "./icon.png", onClick: function () {requirement ("sdk / tabs") Open ("http://www.example.com");}});    

No comments:

Post a Comment