2

Basically window.devicePixelRatio shows the wrong value when used within an iframe. It shows 2.5 on top level but 2 within an iframe.

You can see the value used within an iframe here: https://codepen.io/KennyLindahl/pen/wvBxjGb

Now type window.devicePixelRatio in your devtool console and see that it's not the same value as in the iframe.

A basic local test could look like this in a React render method:

return (
  <React.Fragment>
    <div>{window.devicePixelRatio}</div>
    <iframe src="https://jsfiddle.net/s5k391oa/11/show"></iframe>
  </React.Fragment>
)

Note: I can't write window.devicePixelRatio in codepen because it's also an iframe and will show the same result. So you need to write it in your client js console.


Do anyone know a workaround for this or can explain why that is?

0 Answers0