[Racine des codes] [Page précédente]

popup DHTML

/Html JavaSript/popup_DHTML.html
<script type="text/javascript">
function myPop(txtHtml) {
  var sty, d = document;
  var pop = d.getElementById("myPop");
  if (pop!=null) d.getElementsByTagName("body")[0].removeChild(pop);
  pop = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
  pop.id = "myPop";
  sty = pop.style;
  sty.width='300px';
  sty.fontSize='14px';
  sty.position='absolute';
  sty.right='2px';
  sty.top='2px';
  sty.backgroundColor='#CCC';
  sty.border='2px solid #777';
  var btC = pop.appendChild(d.createElement("div"));
  btC.appendChild(d.createTextNode("X"));
  btC.onclick = function() { document.getElementsByTagName("body")[0].removeChild(document.getElementById("myPop")) };
  sty = btC.style;
  sty.width="14px";
  sty.marginLeft="284px";
  sty.backgroundColor="#FFF";
  sty.border='1px solid #777';
  sty.cursor='pointer';
  //pop.appendChild(d.createTextNode(txt));
  var Feui = pop.appendChild(d.createElement("div"));
  Feui.style.padding='0px 0px 3px 3px';
  Feui.style.backgroundColor='#FFF';
  Feui.innerHTML = (txtHtml=="" ? "Clipboard vide !" : txtHtml);
}

function popQueryString() {
  var txt="", clipb = (window.clipboardData ? window.clipboardData.getData("Text") : "window.clipboardData non supporté");
  var URL_et_QueryString = clipb.split(/[&?]/g);
  for (var ptr=0; ptr<URL_et_QueryString.length; ptr++) {
    txt += URL_et_QueryString[ptr].replace("=", " = ") + '<br>\n';
  }
  myPop(txt);
}

</script>
<body>
<h2>fenêtre/popup en DHTML</h2>
<h2>+ affichage du clipboard (avec "formatage" URL (page+param) qu'il contiend)</h2>
<input type="button" value="Go" onclick="popQueryString()">
[edit]