简体   繁体   English

mozilla firefox中的javascript

[英]javascript in mozilla firefox

how to implement javascript in mozilla firefox addons development? 如何在mozilla firefox插件开发中实现javascript? whether different ways to implement javascript in mozilla firefox with javascript in general? 一般而言,在Mozilla firefox中使用javascript来实现javascript的方式是否不同?

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;
    },

Yes, both these methods can be used to define functions/methods in javascript. 是的,这两种方法都可以用于定义javascript中的函数/方法。 It is not specific to developing firefox extensions. 它不是特定于开发firefox扩展。 You can put any legitimate javascript code in your firefox extension script file. 您可以将任何合法的javascript代码放入firefox扩展脚本文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM