Skip to main content

I am trying to write a JavaScript function to get the current browser width.

I found this one:

javascript:alert(document.body.offsetWidth);

console.log(document.body.offsetWidth);

But its problem that it fail if the body has width 100%.

Is there any other better function or a workaround?

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?

I am trying to write a JavaScript function to get the current browser width.

I found this one:

console.log(document.body.offsetWidth);

But its problem that it fail if the body has width 100%.

Is there any other better function or a workaround?

edited tags
Link
Amr Elgarhy
  • 68.3k
  • 69
  • 190
  • 309
edited body; edited title
Source Link
Brett DeWoody
  • 61.7k
  • 31
  • 139
  • 190

How to get browser width using javascriptJavaScript code?

I am trying to write a javascriptJavaScript 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%.

There isIs there any other better function or a work aroundworkaround?

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%

There is any other better function or a work around?

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?

edited tags
Link
chaos
  • 123.5k
  • 33
  • 305
  • 310
Loading
Source Link
Amr Elgarhy
  • 68.3k
  • 69
  • 190
  • 309
Loading