<body> <div id="demo"></div>
</body>
<script> var demo = document.getElementById("demo"); demo.innerHTML = window.innerWidth || document.documentElement.clientWidth; window.onresize = resize(function () { demo.innerHTML = window.innerWidth || document.documentElement.clientWidth; },30); function resize(fn,delay) { var timer = null; return function () { clearTimeout(timer); timer = setTimeout(fn,delay); } } </script>