Is it possible to trigger a javascript function with Browser's zoom-in and zoom-out?
Asked
Active
Viewed 2,926 times
0
-
What is a *"...Browser's zoom-in and zoom-out"* ? [CTRL]+[+/-/0] ? – Roko C. Buljan Jun 01 '12 at 10:30
-
If it's the zoom event you want to catch, maybe this can help : http://stackoverflow.com/questions/995914/catch-browsers-zoom-event-in-javascript – Timst Jun 01 '12 at 10:30
-
You need to detect keystrokes ctrl+ ctrl- – swapnesh Jun 01 '12 at 10:32
-
1or this http://stackoverflow.com/questions/6163174/detect-page-zoom-change-with-jquery-in-safari – Manse Jun 01 '12 at 10:32
2 Answers
1
Yes friends.... Found the solution....
window.onresize = resize;
function resize() {
alert("Windows is resized...");
}
I hope this will be helpful for you.
OR
This will help you Get Height Width on zoom-in & zoom-out browser
Hardik Patel
- 57
- 1
- 15
-
This does not work consistantly on mobile, see: http://www.quirksmode.org/dom/events/resize_mobile.html – Sorry-Im-a-N00b Oct 31 '14 at 02:58
0
(window.devicePixelRatio*100).toFixed(0) + '%';
you are not triggered the browser's zoom in/out functions but capture the event. This code helps you to capture the browser's current tab zoom in / zoom out percentage ratio.
run the code : chrome -> console -> create live expression -> paste it & enter.
use chrome zoom in/ out the tab
manoz
- 81
- 4
-
4While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Suraj Rao Nov 06 '20 at 18:27