Axel Richter: dialog() mit JA / NEIN

Beitrag lesen

Hallo,

Ist es möglich, per Javascript einen Dialog statt mit "OK"/"Abbrechen" mit "JA"/"NEIN" zu kreieren?

Naja, wenn man _viel_ Lust zum Kreieren hat ...

<html>
<head>
<title></title>
<script type="text/javascript">
<!--
function dialog(text) {
  var d = document.createElement("div");
  a = document.createAttribute("style");
  a.nodeValue = "position:absolute; left:100px; top:100px; width:200px; height:100px; border:1px solid black; text-align:center;";
  d.setAttributeNode(a);

var p = document.createElement("p");
  var t = document.createTextNode(text);
  p.appendChild(t);
  d.appendChild(p);

var bj = document.createElement("button");
  bj.appendChild(document.createTextNode("Ja"));
  a = document.createAttribute("onclick");
  a.nodeValue = "alert('Ja gedrückt!'); window.location.reload();";
  bj.setAttributeNode(a);

var bn = document.createElement("button");
  bn.appendChild(document.createTextNode("Nein"));
  a = document.createAttribute("onclick");
  a.nodeValue = "alert('Nein gedrückt!'); window.location.reload();";
  bn.setAttributeNode(a);

d.appendChild(bj);
  d.appendChild(bn);

var bd = document.getElementById("bd");
  bd.appendChild(d);
}
//-->
</script>
</head>
<body id="bd">
<a href="#" onclick="dialog('Hallo');">Dialog</a>
</body>
</html>

Wie gesagt, hier muss noch viel Energie reingesteckt werden ;-))

Gruß

Axel