window.onresize = function() { document.write(window.outerWidth + '<br/>') }
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script> function p() { document.body.innerText = window.outerWidth + 'px'; } window.onresize = p; p(); </script> </body> </html>