July 22nd in Javascript by .

Create selected text to hyperlink in Javascript

i have come across many many open source WYSISWYG html editors and one thing that kept me always annoying is a popup html window to create a link. Since creating the hyperlink is such an important feature in the wysiwyg editor, keeping it simple is so important.

I just wanted like a prompt asking for URL and then creating a link. No more popup windows. I have searched a lot in the web for such a simple javascript code and its very simple.

function doURL() {
var mylink = prompt("Enter a URL:", "http://");
if ((mylink != null) && (mylink != "")) {
document.getElementById('rte').contentWindow.document.execCommand("CreateLink",false,mylink);
}
}

Similar Posts:

One Comment

  • Adult Dating
    February 11, 2011

Leave A Comment.





Please wrap all source codes with [code][/code] tags. Powered by