A
A
artyvr2015-06-18 22:08:47
JavaScript
artyvr, 2015-06-18 22:08:47

How to get value from textarea?

I'm trying to write a simple extension for Firefox:

var cm = require("sdk/context-menu");
var tabs = require("sdk/tabs");
var self = require("sdk/self");
cm.Item({
    label: "search",
    image: self.data.url("search.ico"),
    //context:
    data: "http://search/?q=",
    contentScript:
                   'self.on("click", function (node, data) {' +
                   '    var text = window.getSelection().toString();' +
                   '    var searchURL = data + text;' +
                   '    self.postMessage(searchURL);' +
                   '});',
    onMessage: function(searchURL) {
                   tabs.open(searchURL);
               }
});

from the context menu the selected text is passed by url...
How to get the value of the selected part of the text from textarea, input ?
thanks in advance...
upd: thanks for the replies!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2015-06-18
@artyvr

And here is the answer: stackoverflow.com/questions/275761/how-to-get-sele...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question