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.
精彩评论