<script type="text/JavaScript">
function myPrompt(msg, val) {
var ret = null;
if (window.showModalDialog) {
var args = {"msg":msg, "val":val};
ret = window.showModalDialog("prompt.html?u="+new Date().getTime(), args, "dialogWidth:315px;dialogHeight:150px;edge:Raised;center:Yes;help:No;resizable:No;status:No");
} else {
ret = prompt(msg, val);
}
return ret;
}
</script>
<button onclick="alert( myPrompt('blabla\n- og en linje mere ...', 'noget') )">TEST</button>
<button onclick="alert( myPrompt('blabla') )">TEST</button>
- og en fil, der hedder 'promt.html':
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Så svar mig dog ...!!!</title>
<style type="text/css">
body, html {
height: 100%;
margin: 0;
background: buttonface;
}
div {
padding: 16px;
}
table {
border-collapse: collapse;
width: 100%;
}
td {
font: 11px tahoma, sans-serif;
vertical-align: top;
}
input {
font: 11px tahoma, sans-serif;
margin: 8px 0;
}
button {
width: 70px;
}
.btns {
text-align: center;
}
#response {
width: 100%;
}
</style>
<script type="text/JavaScript">
window.returnValue = null;
var resp, txt;
function myClose() {
window.returnValue = resp.value;
window.close();
}
window.onload = function() {
var args, captionHeight = 150-document.documentElement.offsetHeight;
resp = document.getElementById("response");
txt = document.getElementById("msgTxt");
args = window.dialogArguments;
resp.value = (args.val)? args.val : "";
txt.innerHTML = args.msg.replace(/\n/g,"<br>");
this.dialogHeight = (document.getElementsByTagName("div")[0].offsetHeight+captionHeight) + "px";
}
</script>
</head>
<body>
<div>
<table>
<col style="width:45px">
<tr>
<td><img src="icon.gif" width="32" height="32"></td>
<td id="msgTxt"> </td>
</tr>
<tr>
<td> </td>
<td><input id="response" type="text"></td>
</tr>
<tr>
<td class="btns" colspan="2"><button onclick="myClose()">OK</button> <button onclick="window.close()">Cancel</button></td>
</tr>
</table>
</div>
</body>
</html>
- så skal du bare lave en ikon på 32*32px, så ligner den