Hey, this could be a tricky one to explain but I'll give it a go...
What I have is a textarea and I'm putting together what is almost like wysiwyg style editing options. So for example the user highlights some words in the textarea and selects the "bold" option and I use this to apply the html tags:
This works just nicely so i thought I would expand and give the users the options to add hyperlinks but obviously I would have to get the URL off them, so once they highlight the required text I have a div pop up to ask them for the URL however as soon as they try to enter this then obviously my original text selection loses focus.
Soooo... my question is, once the user enters the URL in the popup how can I then amend the originally selected text? (does document.selection.createRange() store text location and length?)
Many thanks
Nick
What I have is a textarea and I'm putting together what is almost like wysiwyg style editing options. So for example the user highlights some words in the textarea and selects the "bold" option and I use this to apply the html tags:
Code:
TextSelection= document.selection.createRange().text;
if(TextSelection!=''){
document.selection.createRange().text = "<b>" + TextSelection+ "</b>";
TextSelection.clear();
This works just nicely so i thought I would expand and give the users the options to add hyperlinks but obviously I would have to get the URL off them, so once they highlight the required text I have a div pop up to ask them for the URL however as soon as they try to enter this then obviously my original text selection loses focus.
Soooo... my question is, once the user enters the URL in the popup how can I then amend the originally selected text? (does document.selection.createRange() store text location and length?)
Many thanks
Nick