Is there a way to get the a users screen size/resolutions using javascript? I figured you probably can't use PHP to do this as it's server-side, but as javascript is client-side I thought it may be an option.
Use window. innerWidth and window. innerHeight to get the current screen size of a page.
availWidth property returns the width of the visitor's screen, in pixels, minus interface features like the Windows Taskbar.
width read-only property returns the width of the screen in CSS pixels.
You can use window. innerHeight and window. innerWidth to get the size of the window for the web page as the user sees it.
Yes, you can use the following to print out the resolution for example:
<script type="text/javascript">
document.write(screen.width+'x'+screen.height);
</script>
Might not work in older browsers, but will in most recent ones.
More info here:
http://www.javascriptkit.com/howto/newtech3.shtml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With