开发者

javascript in mozilla firefox

开发者 https://www.devze.com 2023-01-28 18:07 出处:网络
how to implement javascript in mozilla firefox addons development? whether different ways to implement javascript in mozilla firefox with javascript in general?

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

精彩评论

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