javascript - The Mathematical Operators not working on window.innerWidth -
when use mathematical operators window.innerwidth returs nan.
i tried add numeric 1 window.innerwidth.
what's wrong code?
<body> <p>click button display window's height , width (not including toolbars , scrollbars).</p> <button onclick="myfunction()">try it</button> <p id="demo"></p> <script> function myfunction() { var w = window.innerwidth; var h = window.innerheight; x = document.getelementbyid("demo"); x.innerhtml = "width: " + w-1 + " heigth: " + h; } </script> </body>
change innerhtml code as
x.innerhtml = "width: " + (w-1) + " heigth: " + h;
modify javascript code below
here modified plunker
function myfunction() { var w = window.innerwidth; var h = window.innerheight; x = document.getelementbyid("demo"); x.innerhtml = "width: " + (w-1) + " heigth: " + h; }
Comments
Post a Comment