Jeg fik strikket denne her sammen, jeg skylder nok at nævne at min editor er en videreudvikling af den gratis editor htmlarea, og den popup jeg har lavet kan nemt erstatte den indbyggede:
<html STYLE="width: 450px; height: 204px; ">
<head><title>Indsæt tabel</title><head>
<style>
html, body, button, table, div, input, select, fieldset {
font-family :Trebuchet MS, Verdana, Tahoma, Arial;
font-size :12px;
}
</style>
<script>
// if we pass the "window" object as a argument and then set opener to
// equal that we can refer to dialogWindows and popupWindows the same way
opener = window.dialogArguments;
var _editor_url = opener._editor_url;
var objname = location.search.substring(1,location.search.length);
var config = opener.document.all[objname].config;
var editor_obj = opener.document.all["_" +objname+ "_editor"];
var editdoc = editor_obj.contentWindow.document;
function _CloseOnEsc() {
if (event.keyCode == 27) { window.close(); return; }
}
window.onerror = HandleError
function HandleError(message, url, line) {
var str = "An error has occurred in this dialog." + "\n\n"
+ "Error: " + line + "\n" + message;
alert(str);
// window.close();
return true;
}
function Init() {
document.body.onkeypress = _CloseOnEsc;
}
function _isValidNumber(txtBox) {
var val = parseInt(txtBox);
if (isNaN(val) || val < 0 || val > 9999) { return false; }
return true;
}
function btnOKClick() {
var curRange = editdoc.selection.createRange();
// error checking
var checkList = ['txtLinkAddress','txtLinkName'];
for (var idx in checkList) {
var fieldname = checkList[idx];
if (document.all[fieldname].value == "") {
alert("You must specify a value for the '" +fieldname+ "' field!");
document.all[fieldname].focus();
return;
}
}
// delete selected content (if applicable)
if (editdoc.selection.type == "Control" || curRange.htmlText) {
if (!confirm("Overwrite selected content?")) { return; }
curRange.execCommand('Delete');
curRange = editdoc.selection.createRange();
}
// create link
var linket = ' <a href="' + document.all.txtLinkType.value + document.all.txtLinkAddress.value + '" target="' + document.all.txtLinkTarget.value + '">' + document.all.txtLinkName.value + '</a> ';
// insert link
opener.editor_insertHTML(objname, linket);
// close popup window
window.close();
}
var changeable = true;
function initier() {
if(document.all.txtLinkAddress.value == document.all.txtLinkName.value) {
changeable = true;
}
if(document.all.txtLinkAddress.value != document.all.txtLinkName.value) {
changeable = false;
}
}
function tjekType() {
if(document.all.txtLinkName.value == '') {
changeable = true;
}
if(changeable == true || document.all.txtLinkName.value == '') {
if (document.all.txtLinkType.selectedIndex==1) {
document.all.txtLinkName.value = document.all.txtLinkAddress.value;
}
}
}
function tjekType2() {
if(changeable == true || document.all.txtLinkName.value == '') {
if (document.all.txtLinkType.selectedIndex==1) {
if(document.all.txtLinkAddress.value!=document.all.txtLinkName.value) {
var changeable = false;
}
}
}
}
</SCRIPT>
</HEAD>
<BODY id=bdy onload="initier();document.all.txtLinkAddress.focus();Init()" style="background: threedface; color: windowtext; BORDER-STYLE: none" scroll=no>
<table width="100%" border=0 cellspacing=6 cellpadding=0>
<tr><td nowrap>Link: </td><td><select name="txtLinkType" tabindex="0">
<option value="
http://">webadresse</option><option value="mailto:">email</option>
<option value="">intern fil</option>
</select></td><td style="width:100%"><INPUT type="text" onfocus="select();tjekType2()" onkeyup="tjekType()" onchange="tjekType()" style="width:100%" name="txtLinkAddress" tabindex="1"></td><td><BUTTON style="width:70px" type="button" onclick="btnOKClick()" tabindex="4">OK</BUTTON></td></tr>
<tr><td>Linknavn: </td><td colspan="2"><INPUT type="text" style="width:100%" name="txtLinkName" tabindex="2" onblur="initier()" onfocus="select()"></td><td><BUTTON style="width:70px" type="button" onClick="window.close();" tabindex="5">Annuller</BUTTON></td></tr>
<tr><td>Åbn i: </td><td colspan="2" width="100%"><SELECT style="width:100%" name="txtLinkTarget" tabindex="3">
<OPTION value="_blank">Nyt vindue</OPTION>
<OPTION value="_self" selected>Samme vindue</OPTION>
</SELECT>
</td></tr>
</table>
</BODY>
</HTML>