0

Is it possible to trigger a javascript function with Browser's zoom-in and zoom-out?

skeletank
  • 2,850
  • 5
  • 44
  • 73
aneeshraj
  • 91
  • 1
  • 9

2 Answers2

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
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
  • 4
    While 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