开发者

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.crea开发者_运维技巧teRange();
   }
   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;
    },


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜