user495688
user495688

Reputation: 973

javascript in mozilla firefox

how to implement javascript in mozilla firefox addons development? whether different ways to implement javascript in mozilla firefox with javascript in general?

for example if I want to create a function like this:

function selectedText () {
var userSelection;
   if (window.getSelection) {
      userSelection = window.getSelection();
   } else if (document.selection) {
       userSelection = document.selection.createRange();
   }
   return userSelection;
}

whether the same function if I write the function like this:

  selectedText : function () {
    var userSelection;
       if (window.getSelection) {
          userSelection = window.getSelection();
       } else if (document.selection) {
           userSelection = document.selection.createRange();
       }
       return userSelection;
    },

Upvotes: 0

Views: 315

Answers (1)

euphoria83
euphoria83

Reputation: 15136

Yes, both these methods can be used to define functions/methods in javascript. It is not specific to developing firefox extensions. You can put any legitimate javascript code in your firefox extension script file.

Upvotes: 1

Related Questions