- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is cross-browser window resize events in JavaScript?
For window resize event in JavaScript, use addEventListener(). The following code will give you the size of the current window −
Example
<!DOCTYPE html> <html> <head> <style> div { margin-top: 10px; padding: 10px; background-color: #1E9E5D; width: 50%; } span { font-size: 50px; } </style> <script> window.addEventListener('resize', display); function display() { document.querySelector('.width').innerText = document.documentElement.clientWidth; document.querySelector('.height').innerText = document.documentElement.clientHeight; } display(); </script> </head> <div> <span>Width= <span class="width"></span></span><br /> <span>Height= <span class="height"></span></span> </div> </body> </html>
- Related Articles
- How to Resize Browser Window in WebDriver?
- Which is the event when the browser window is resized in JavaScript?
- What's the best way to open new browser window using JavaScript?
- How can I resize the root window in Tkinter?
- Setting Cross Browser Opacity using CSS
- Best Cross Browser Compatibility Testing Tools
- What are events in JavaScript?
- Cross Browser Solution for Image Marker in CSS
- Dynamically Resize Buttons When Resizing a Window using Tkinter
- Resize the Tkinter Listbox widget when the window resizes
- 20 Best Cross Browser Compatibility Testing Tools
- Execute a script when the browser window is closed in HTML?
- What are custom events in JavaScript?
- Get the size of the screen, current web page and browser window in JavaScript
- How to resize the background image to window size in Tkinter?

Advertisements