To get selected text with new line characters?

We are developing one Chrome extension. In which we tried to get the selected text in the browser tab using the context menu option and we got an empty string as the selected text using the following method in background.js

window.getSelection().toString()


Then referenced that link and changed the way to get the selected text as

chrome.contextMenus.create({title: "Click", contexts:["selection"], onclick: function(info, tab) { selectedText = info.selectionText; });
Using this method I can able to get the selected text as string ( single line ) with no line breaker. Is it possible to get the selected text with line by line ( with new line characters ) content? Get the text as how it is presented in browser.
For Example:
If this is the content,
Text first line Text second line


I get the selected text as "First line text Second line text". There is no delimiter or any other special characters that end a newline or the end of a line. In my extension, this suggestion will really help.

+3
google-chrome google-chrome-extension contextmenu


source to share


No one has answered this question yet

See similar questions:

1
Chrome getSelection not working if called from context menu

or similar:

1153
How do I get ASP.NET Web API to return JSON instead of XML using Chrome?
1058
Getting Chrome to accept self-signed local certificate
949
How to remove border (outline) around text / input fields? (Chromium)
ten
Selecting text in Google Docs
nine
javascript text selection events
7
Get page selection including HTML?
1
chrome text text for formatting
1
get selected text in chrome extension
0
get url of selected link in chrome extension
0
adding highlighted text to webpage in field in added chrome extension on sidebar on click



All Articles
Loading...
X
Show
Funny
Dev
Pics