Questions tagged [getselection]
198 questions
0
votes
1 answer
using getSelection to wrap a link within a link
I have been staring at this problem for some time now and have not managed to get a working solution.
I am using the Rangy library to ensure best support for Ranges.
Objectives
Make a selection and wrap with a link. Even if the selection is within…

kylewelsby
- 4,031
- 2
- 29
- 35
0
votes
1 answer
How to save and restore anchorNode/anchorOffset & focusNode/focusOffset?
In the following code:
var s=window.getSelection();
var sr=s.getRangeAt(0);
console.log(s.anchorOffset+" "+s.focusOffset);
s.removeAllRanges();
s.addRange(sr);
console.log(s.anchorOffset+" "+s.focusOffset);
The anchorOffset and focusOffset are…

poby
- 1,572
- 15
- 39
0
votes
1 answer
.getSelection new code duplicating plus one each click
Yes I had an old post, nearly same question, yet when I took the time and wrote this myself instead of using @Tim Downs code I got closer than I even thought I would. Only problem now is that each time I click the button it adds another piece so…

EasyBB
- 6,176
- 9
- 47
- 77
0
votes
2 answers
scrollTop and getSelection()
ok so I have two codes, issues with both. They go hand in hand, so please don't say make two separate post. I need the scrollTop to work after the second code is finished. Thank You
This part is DONE~!
$('html,body').animate({
scrollTop: '+=' +…

EasyBB
- 6,176
- 9
- 47
- 77
0
votes
1 answer
How to extract styled text from div to a Selection object JavaScript and other
Ok, I have 2 problems, I've gotten internet explore to replace selected text with the text from a div element but I haven't managed to do it with firefox (the 'no idea' bit) and ontop of that I can't for the life of me figure out how to get the…

Olivier Molliés
- 21
- 6
0
votes
1 answer
How to replace a text at a the same index with JavaScript?
How to replace a text at a the same index. This text may have the same pattern. Say I want to replace the bold "is" in the next text.
"Sam is a boy and Dory is his sister, but John is his father. He isn't a doctor."
when I use the following code it…

Develop Smith
- 146
- 1
- 3
- 13
0
votes
1 answer
ckeditor javascript code EditorInstance.document.getSelection().getStartElement() working on Firefox but Not Working in IE
Node JAVASCRIPT CODE:
Editor= CKEDITOR.instances['ckeditor1'];
getElem=Editor.document.getSelection().getStartElement();
getElem.setHtml("SomeText ");
Working On : FireFox
not working On : Internet Explorer
The Error is…

RGA
- 602
- 2
- 9
- 39
0
votes
1 answer
xul-Get selection html
I have the following function that is supposed to get HTMLs for the user selected area on the web page. This function does not seems to work properly.
Sometime, it gets htmls which is not selected also.
Can anyone please look into this function? --…

Murali Bala
- 43
- 1
- 6
0
votes
1 answer
Range startContainer isn't the deepest node
I want to generate an array of nodes in a page, which will have all of the possible startContainers for Ranges.
I've tried to use a treeWalker but it gives me a node which is deeper than the actual startContainer node, for example:
For those…

funerr
- 7,212
- 14
- 81
- 129
0
votes
2 answers
Retrieve selected text in IE
Possible Duplicate:
getSelection() not working in IE
I was trying to get the selected content, and I found this:
window.getSelection().toString();
It works in most of the browser, except the obvious, IE.
So, what to do?

user1691388
- 138
- 1
- 7
0
votes
3 answers
I want my input to be written leftwards
I know this is possible in javascript by using window.getSelection() method but I'm not familiar with this selection object.
Can you help me to write a code to make user's writing cursor to be always at the begining of the input…

Yunus Eren Güzel
- 3,018
- 11
- 36
- 63
0
votes
1 answer
Firefox: paragraph selection with triple click produces behavior that's not what I would expect
Triple-clicking the mouse to select a paragraph sets document.getSelection().leftOffset to 0 (which seems right) but the rightOffset property is set to 1, so code that processes the selection produces results consistent with only the first character…

Lori
- 1,392
- 1
- 21
- 29
-1
votes
2 answers
Need get all A tags in selection in editable iframe and add them attribute "class"
I have an editable
user980966
-1
votes
1 answer
App Script Google Docs Extension Selects Too Much Text
The intention is for the extension to grab the selected text and pop it into a card search engine, then return the resulting webpage as a hyperlink attached to the selected text. The first half of that works fine however the printing seems to…

fluctuating
- 13
- 2
-1
votes
1 answer
why window.getSelection() is not working? It won't take the text
I'm trying to paste in the console the text from the screen that I select.
So, I've got some example text and in my js file I have:
let text = window.getSelection().toString()
console.log(text)
That's the only content of the file, as this is a…

Rosamunda
- 14,620
- 10
- 40
- 70