diff --git a/www/extras/htmlArea/editor.js b/www/extras/htmlArea/editor.js
index c049f7feb..ee0a84ff1 100644
--- a/www/extras/htmlArea/editor.js
+++ b/www/extras/htmlArea/editor.js
@@ -372,10 +372,63 @@ function editor_action(button_id) {
if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); }
if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); }
- // insert link
- if (cmdID.toLowerCase() == 'createlink'){
- editdoc.execCommand(cmdID,1);
- }
+ // insert link (modified)
+ if (cmdID.toLowerCase() == 'createlink') {
+ if (editdoc.selection.createRange().text != "") {
+ var highlightedText = editdoc.selection.createRange().text;
+ }
+ else { var highlightedText = ""; }
+
+ var href_attribute = '';
+ var tar_attribute = '';
+ var linkText = '';
+
+ if (editdoc.selection.createRange().parentElement().outerHTML.search(/^\<[A|a]/) != -1) {
+
+ var fullElement = editdoc.selection.createRange().parentElement().outerHTML;
+ fullElement = fullElement.replace(/\"/g, "");
+ fullElement = fullElement.replace(/\'/g, "");
+
+ // here, we have an tag. Now let's extract...
+ // 1. the href attribute
+ var href_value = fullElement.split(/href=/);
+ href_value2 = href_value[1].split(/\s|>/);
+ href_attribute = href_value2[0];
+
+ // 2. the target attribute
+ if (fullElement.search(/target=/) != -1) {
+ var tar = fullElement.split(/target=/);
+ tar2 = tar[1].split(/\s|>/);
+ tar_attribute = tar2[0];
+ }
+ else { tar_attribute = ''; }
+
+ // 3. the link text
+ var linkText2 = fullElement.split(/>/);
+ var lt = linkText2[1].split(/);
+ linkText = lt[0];
+
+ }
+
+ var myValues = new Object();
+ myValues.highlightedText = highlightedText;
+ myValues.tar_attribute = tar_attribute;
+ myValues.href_attribute = href_attribute;
+ myValues.linkText = linkText;
+
+ var myText = showModalDialog(_editor_url + "popups/insert_link.html", myValues, "status=no; scroll=no");
+
+ if (linkText != '') {
+ if (myText) {
+ editdoc.selection.createRange().parentElement().outerHTML = '';
+ editor_insertHTML(objname, unescape( myText) );
+ }
+ }
+ else {
+ if (myText) { editor_insertHTML(objname, unescape(myText) ); } // this function ALWAYS puts in an absolute link
+ }
+
+ }
// insert image
else if (cmdID.toLowerCase() == 'insertimage'){