Hi, I am trying to create an add link button to a wysiwyg editor, anyways… What i have is a new window pops up asking for user input, the variables are then passed back from the window, then I need to make a link using the varialbes theUrl, TheTarget, and maybe theTitle.

url = theUrl + "\\" " + "target=" + "\\"" + theTarget;
theIframe.contentWindow.document.execCommand("CreateLink", false, url);

This gives me a link with the hex codes for " and space.

<a href="">asdf</a>

I also tried using this but I cannot get theSelection to be the text that is selected.

theSelection = theIframe.contentWindow.getSelection();
theRange = theSelection.getRangeAt(0);
var newLink = theIframe.contentWindow.document.createElement("a");
var someText = document.createTextNode(theSelection); = theTarget;
newLink.href = theUrl;
newLink.title = theTitle;

Thanks for any advice.

try using the unescape function of javascript

[left]url = theUrl + "\\" " + "target=" + "\\"" + theTarget;[/left]
[left]url = unescape(url)
theIframe.contentWindow.document.execCommand("CreateLink", false, url);[/left]

Try using extractContents() instead of collapse().

Thank you, extractContents() is exactly what i was looking for, worked perfectly.

i used the above code
but iam not getting exact answer
o/p-- (if i use \“) – <a href = '” target = “_blank’>
(if i use \‘) – <a href = "’ target = '_blank”>
i want to add target attribute to anchor tag for above example
try to solve my problem