I tried one of this scripts from this url:
http://groups.google.com/group/chromium-extensions/browse_thread/thread/eab847f0a32ec25c/c6dd63ca74efad4b?#c6dd63ca74efad4b
-------background.html:-----------
<html>
<head>
<script type="text/javascript">
/*
var selection_callbacks = [];
function getSelection(callback) {
selection_callbacks.push(callback);
chrome.tabs.executeScript(null, { file:"content_script.js" });
};
chrome.extension.onRequest.addListener(function (request) {
var callback = selection_callbacks.shift();
callback(request);
});
*/
function getSelection() {
chrome.tabs.executeScript(null, {file: "content_script.js"});
}
chrome.extension.onRequest.addListener(function(request) {
alert("got selection: " + request);
});
</script>
</head>
<body></body>
</html>
-----------content_script.js---------------------
chrome.extension.sendRequest(window.getSelection());
---------------manifest.json-------------------------------------
{
"name": "xyz",
"description": "xyz",
"version": "1.2.5",
"background_page": "background.html",
"icons": { "128": "xyz.png" },
"permissions": [
"tabs", "http://*/*", "https://*/*"
],
"browser_action": {
"default_title": "xyz",
"default_icon": "xyz.png",
"popup" : "popup.html"
}
}
-----------------------popup.html-------------------
<html>
<head>
<script type="text/javascript">
function onSelection(text) {
document.getElementById("output").innerHTML = text;
}
//
chrome.extension.getBackgroundPage().getSelection(onSelection);
alert("Selected Text is : " +
chrome.extension.getBackgroundPage().getSelection());
</script>
</head>
<body>
<div id="output">This should be replaced with the selected text</
div>
</body>
</html>
My OS: Ubuntu
Chrome Version: Chromium 5.0.321.0
i tried on windows as well
on windows i have chrome version 4.0.249.78
have no luck with me, is there any version conflict?
please help me guys,
Thanks,
Gopi
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.