getselection

getSelection() for iPhone bookmarklet

孤街浪徒 提交于 2019-12-11 06:41:40
问题 I've done a bit of research but can't seem to find a definitive answer regarding getting the currently selected text via getSelection() in an iPhone bookmarklet. Is this still possible? It seems that from various searches there are a number of bookmarklets available that use a similar behaviour, but none appear to work for me. I'm simply selecting some text on my iPhone, waiting for the draggable box to appear (along with the Copy button) and then tapping the Bookmark icon in MobileSafari and

window.getSelection().getRangeAt() not working properly

元气小坏坏 提交于 2019-12-11 04:48:16
问题 I am trying to get the text selection within a an html element and then insert span tags around it. So far, I am having problems with the correct indices. If I highlight text inside a <p> block, the index goes to 0 after a <br> tag. I want to be able to slice() the text out and then recombine it with span tags after highlighting the text as well as grabbing the selected text and sending it to server via Ajax. Here is some sample HTML and code: <html><body><p>This is some sample text.<br

how to get selected text from iframe with javascript?

拥有回忆 提交于 2019-12-10 22:04:49
问题 how to get selected text from iframe with javascript ? 回答1: var $ifx = $('<iframe src="filename.html" height=200 width=200></iframe>').appendTo(document.body); $(document.body).bind('click', function(){ var u_sel; if(window.getSelection){ u_sel = ifx[0].contentWindow.getSelection(); // u_sel.text() InternetExplorer !! alert(u_sel); } }); That should do it, as long as the iframe src is targeting your own domain . Tested only on FireFox 3.6.7 so far. 回答2: function getIframeSelectionText(iframe)

How to wrap html tag for jquery mouseup selection wrods?

ⅰ亾dé卋堺 提交于 2019-12-08 19:23:32
I have reference the answer here Select whole word with getSelection . I would like to make a mouseup selection completed words from body . than wrap <p> tag for the selection words . Here is the code. So how to? Thanks. <script src="jquery.js"></script> <script> (function($) { function getSelected() { if(window.getSelection) { return window.getSelection(); } else if(document.getSelection) { return document.getSelection(); } else { var selection = document.selection && document.selection.createRange(); if(selection.text) { return selection.text; } return false; } return false; } function

A better way to extract innerText around getSelection()

百般思念 提交于 2019-12-08 05:36:13
问题 I'm working on a Chrome extension that will extract a plain text url from a selection, but the selection will always be a fraction of the url, so I need to scan left and right. I basically need to extract 500 characters around the selection from innerText, since I don't want to parse html elements, and also don't want to re-assemble textContent's. Here's what I have so far, it's working quite well, but I feel there's a better way that doesn't modify the document object and then restore it

How to wrap html tag for jquery mouseup selection wrods?

两盒软妹~` 提交于 2019-12-08 05:30:24
问题 I have reference the answer here Select whole word with getSelection. I would like to make a mouseup selection completed words from body . than wrap <p> tag for the selection words . Here is the code. So how to? Thanks. <script src="jquery.js"></script> <script> (function($) { function getSelected() { if(window.getSelection) { return window.getSelection(); } else if(document.getSelection) { return document.getSelection(); } else { var selection = document.selection && document.selection

How to wrap selected text with a div in ipad?

笑着哭i 提交于 2019-12-06 05:06:55
Its a followup question of this . I'm trying to wrap the selected text in a div using window.getSelection() but its not working in iPad because window.getSelection().rangeCount is 0. Demo: http://jsfiddle.net/codef0rmer/jE4w5/ Is there any workaround for this to work in iPad? You can use rangy for text selection and highlighting. jQuery Mobile along with backbone.js breaks the page so I used jQuery FastClick plugin 来源: https://stackoverflow.com/questions/11465253/how-to-wrap-selected-text-with-a-div-in-ipad

Get Chosen App from Intent.createChooser

左心房为你撑大大i 提交于 2019-12-06 00:18:42
问题 I am trying to capture the result of Intent.createChooser to know which app a user selected for sharing. I know there have been a lot of posts related to this: How to know which application the user chose when using an intent chooser? https://stackoverflow.com/questions/6137592/how-to-know-the-action-choosed-in-a-intent-createchooser?rq=1 How to get the user selection from startActivityForResult(Intent.createChooser(fileIntent, "Open file using..."), APP_PICKED);? Capturing and intercepting

Google Chart getSelection doesn't have column property

爱⌒轻易说出口 提交于 2019-12-05 16:57:28
When I use: chart.getChart().getSelection()[0] on a chart (from a chartwrapper, hence the getChart() first), the getSelection() function returns only a row-property but no column property even though my 'chart' is a table and clicking anywhere within it should return both a row and column property. Is this a known google charts bug? Does anyone know of a workaround? Also I have found this topic on google groups: https://groups.google.com/forum/#!topic/google-visualization-api/O_t7-s96A9w here they say: Currently the Table object only supports row selection and therefore the column property is

Javascript selected text highlighting prob

99封情书 提交于 2019-12-04 07:50:19
问题 I have a html page with text content. On selecting any text and pressing the highlight button, I can change the style of the selected text to highlight the same. To implement this feature, i have written the following method. sel = window.getSelection(); var range = sel.getRangeAt(0); var span = document.createElement('span'); span.className = "highlight" + color; range.surroundContents(span); This is working fine if you choose a text with no html tag, but when the text has any html tag in