Javascript alert() function not working when user scan QR code

I just found out that, when user scan QR code and click "Open in browser" to go to my website, the javascript alert function will not work.

Anyway to fix it?
Or anyway to make it open in safari window after scanning the QR code?

I double checked if user click the safari icon and go to our website alert can work without any problem. However when users scan qr code, alert cannot work and cause problems.

Javascript alert() function not working when user scan QR code
 
 
Q