87913/how-to-get-browser-width-using-javascript-code
I am trying to write a JavaScript function to get the current browser width.
I found this one:
javascript:alert(document.body.offsetWidth);
But its problem that it fail if the body has width 100%.
Is there any other better function or a workaround?
Hello @kartik,
Use this code:
var w = window.innerWidth; var h = window.innerHeight; var ow = window.outerWidth; //including toolbars and status bar etc. var oh = window.outerHeight;
Both return integers and don't require jQuery. Cross-browser compatible.
Hope it helps!!
Thank You!!
You have to download the file with ...READ MORE
Hello @kartik, Use this: var filename = fullPath.replace(/^.*[\\\/]/, '') This ...READ MORE
Hello @kartik, Use: var host = window.location.hostname; or possibly var host ...READ MORE
Hii @kartik, Using javascript <script> $("a[href='#top']").click(function() { ...READ MORE
Hello, In the error callback or $.ajax you have three ...READ MORE
Hello @kartik, If your script is called myScript.js ...READ MORE
Hello @kartik, Try this code : // Create an ...READ MORE
Hello @kartik, Use node-inspector from any browser supporting WebSocket. Breakpoints, ...READ MORE
Hii, This works in all browsers: window.location.href = '...'; If ...READ MORE
Yes it is possible. You can either ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.