When making an URL by using the nifty javascript that's built in, there is no
Code: Select all
target="_blank"
So I wrote this - I know - lame hack (taken from serendipity_editor.js - anyone is ofc free to use this code if they are experiencing the same annoyance as me)
Code: Select all
function wrapSelectionWithLink(txtarea) {
var my_link = prompt("Enter URL:","http://");
var my_target = prompt("Enter Target:","target=_blank");
if (document.all && getIESelection(txtarea) == "" ||
document.getElementById && getMozSelection(txtarea) == "") {
var my_desc = prompt("Enter Description", '');
}
if (my_link != null & my_target!= null) {
lft = "<a href=\"" + my_link + "\" \"" + my_target + "\">";
if (my_desc != null && my_desc != "") {
rgt = my_desc + "</a>";
} else {
rgt = "</a>";
}
wrapSelection(txtarea, lft, rgt);
}
return;
}
Code: Select all
lft = "<a href=\"" + my_link + "\" \"" + my_target + "\">";
Output of all this is;
Code: Select all
<a href="http://www.marinmo.net" "target=_blank">Marinmo.net</a>
If any of the developers, or me, comes up with a better solution for this (there must be), I would appreciate if they would post it here and include it in the next stable, if they find it reasonable (they should! ).