要使用换行符添加选定的文字?

时间:2014-09-02 11:48:24

标签: google-chrome google-chrome-extension contextmenu

我们正在开发一个Chrome扩展程序。我们尝试使用上下文菜单选项在浏览器选项卡中获取所选文本,并通过在background.js中使用以下方法将空字符串作为选定文本获取

window.getSelection().toString()

然后引用此link并更改了将所选文本设为

的方法

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

我将所选文本作为"文本第一行文本第二行"。这里没有分隔符或任何其他特殊字符,这些字符与新行或行尾相关。在我的推文中,暗示将真正有用。

0 个答案:

没有答案