I'm quite new to HTML/CSS/Javascript and I have been following this example to create an interactive zoom of another image. The code works fine for me. It also works if the size of the input image is not absolute, but given in percentages. You can see this here by changing the line
<img id="myimage" src="img_girl.jpg" width="300" height="240">
to
<img id="myimage" src="img_girl.jpg" width="50%" height="50%">
However, switching to percentage-based image size introduces a problem. If the browser window is resized, the zoomed image no longer aligns with the lens. This problem goes away if I refresh the window.
So, how can I tell my JavaScript imageZoom() function that the browser window has been resized, the target image has changed dimensions, and therefore the function variables have changed?