How to insert a link using execCommand that prompts users for a title first?

Hello, I am having a problem with my wysiwyg editor for my site, users dont like the fact that you have to select text before you create a link and I was wondering if it was possible to prompt the user to add title text before you use the execCommand(‘createlink’) and use that has the select text that they made from the prompt. Instead of the old way where you must select text first to use execCommand(‘createlink’) to create a link. kind of like Sitepoint’s insert link function but instead prompts the user for the title and doesn’t insert bbcode but a anchor tag?

execCommand is JScript so it only runs in Internet Explorer. Unless you are creating intranet pages that only run on IE you should avoid it.

Well execCommand seems to be working in all browsers, from what I see.

Anyone can help with this issue?

http://www.quirksmode.org/dom/execCommand.html

Solved.

If you don’t mind saying, what was your solution?

Pretty much using execCommand(‘inserthtml’) and just prompting the user for title text and the url, then used that command to insert the anchor tag. Then after that I came to a problem with IE6/7 support on execCommand(‘inserthtml’) and I found a way to work around it since it has been done before in this example:

rteName = “Name of your editor IFRAME”;
function rteInsertHTML(html) {
if (document.all) {
var oRng = document.getElementById(rteName).contentWindow.document.selection.createRange( );
oRng.pasteHTML(html);
oRng.collapse(false);
oRng.select();
} else {
document.getElementById(rteName).contentWindow.document.execCommand(’insertHTM L’, false, html);
}
};

I didn’t do it exactly like that but pretty much how its done to fix the issue.