ip: 3.143.23.38 DKs blog - HTML/javascript examples

DK's Blog

HTML/javascript examples

HTML example of DIV over DIV

< div id="masterDiv" style="position: relative; top: 0; left: 0; overflow: hidden; height: 100%; width: 100%;">
  < div id="div1" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
     lowest layer
  < /div>
  < div id="div2" style="position: absolute; top: 0px; left: 0px; height: 100%; width: 100%;">
    < img src="image.jpg" height="100" width="100%">
  < /div>
  < div id="div3" style="position: absolute; top: 0; left: 0; height: 100%; width: 100%; vertical-align: middle;">
    <  h1>highest layer
  < /div>
<  /div>


   

highest layer


 


How to disable browser cache from HTML

 

< meta http-equiv="cache-control" content="no-cache" / >
< meta http-equiv="pragma" content="no-cache" / >
< meta http-equiv="expires" CONTENT="0" / >


 

How to allow only numeric entry in text form (allow only numbers and one dot), works in IE, Chrome, Firefox

 

< !DOCTYPE html >
< html >
< head > 
  < meta http-equiv="content-type" content="text/html; charset=windows-1250" / > 
< /head >
< body >
 < form >
  < input type="text" id="number_field" onkeypress="numeric('number_field',event);" / >
  < input type="button" onClick="numericEnd('number_field');" value="stisni" / >
 < /form >

 < script type="text/javascript" charset="windows-1250" >
 function numeric(val, e)
 {
    var unicode=e.keyCode? e.keyCode : e.charCode;
    if (unicode==8) return;
    var arr = (document.getElementById(val).value + String.fromCharCode(unicode).replace(/[^\d.]/, "")).match(/(\d+\.?\d*)/g);
    if (arr != null) document.getElementById(val).value = arr[0];

    if(e.preventDefault) e.preventDefault();
    else e.returnValue = false;
    
 }
 function numericEnd(val)
 {
    if (document.getElementById(val).value.charAt(document.getElementById(val).value.length - 1) == '.') document.getElementById(val).value += '0';
 }
 < /script >
< /body >
< /html >

 


How to add support for .startswith() in Ineternet Explorer

 

if (!String.prototype.startsWith) {
  String.prototype.startsWith = function(searchString, position) {
    position = position || 0;
    return this.indexOf(searchString, position) === position;
  };
}

 

 


 

@2016