event handling - Javascript addEventListener not reading resize -


hi i'm trying add eventlistener adds h1 tag width , height of browser when resize it. don't understand why it's not working.

<!doctype html>  <html>  <head>  	<title>window size</title>      </head>      <body>    <div id="wh"></div>    <script type="text/javascript">    "use strict";    document.addeventlistener("onresize", function(){    	var width = document.documentelement.clientwidth;  	var height = document.documentelement.clientheight;    	document.getelementbyid('wh').innerhtml = "<h1>width: " + width + "  height: " + height + "</h1>";    });      </script>      </body>  </html>

you have wrong event, needs 'resize'. see here further examples - http://www.w3schools.com/jsref/event_onresize.asp

<!doctype html>  <html>  <head>  	<title>window size</title>      </head>      <body>    <div id="wh"></div>    <script type="text/javascript">    "use strict";    window.addeventlistener("resize", function(){    	var width = document.documentelement.clientwidth;  	var height = document.documentelement.clientheight;    	document.getelementbyid('wh').innerhtml = "<h1>width: " + width + "  height: " + height + "</h1>";    });      </script>      </body>  </html>


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -