If a web page is zoomed out/in in any modern browser, then how I can find size of a DIV element at 100% zoom?
EDIT:: I asked another similar question here, which was unanswered.
If a web page is zoomed out/in in any modern browser, then how I can find size of a DIV element at 100% zoom?
EDIT:: I asked another similar question here, which was unanswered.
Do you know the original size? At least in IE7+ you can figure out zoom level and figure out the proportions:
zoomLevel = Math.round((self.document.body.parentElement.offsetWidth / self.document.body.offsetWidth) * 100);
If you're using jQuery, you can use the $('#div').width()
or $('#div').outerWidth()
method to find it very easily. There are equivalents in other JS libraries, so just ask if you want to know the method in your framework of choice
You can use pure JavaScript to get the width and height like so:
// Create an object of the div.
var divElement = document.getElementById('id of div');
// Retrieve the height and width.
var width = divElement.getAttribute('width');
var height = divElement.getAttribute('height');
It's possible to do the same thing with jQuery or any other library and it's generally faster and easier that way.