How can I stop being redirected to the App Store/Google Store by dodgy ad-scripts? There are a load of sites that do this now, and it's really annoying:


I visit a content site on my Android device.
10-15 seconds after loading starts the site hangs for a few seconds.
Google play store loads with a garbage app (usually some awful FTP or useless battery app) pre-selected.


This appears to be because a dodgy ad-script (i.e. Javascript running in the web page) is somehow able to redirect my device to open a link to an application in the store without me selecting it directly.

I consider it to be a critical security fail that Android lets this happen, but then Iphones do the exact same thing (but hang for much longer opening the app store).

This isn't me accidentally clicking on anything - the site loads, then the play-store redirect fires, every time. 

Is there any way to stop this? Any option I can set in the store or browser to stop this incredibly annoying behaviour?

I'm on a Nexus 7, but I've seen this on lots of other Android devices.
You can't stop websites redirecting you to other sites: that's just how the web works. What you can do is stop links to apps on Google Play opening in the Play Store app.

Android 6 (Marshmallow):
From the main device settings, go to Apps, then find Google Play Store in the list, click Open by default, then Open supported links, then Don't open in this app.

Older Android:
From the main device settings, go to Apps, then find Play Store in the list, and click Clear defaults.
Next time a website redirects you to a Google Play link, you'll get a chooser asking you whether to open it in the browser (it'll give you a choice of browsers if you have several installed) or with the Play Store app. Select the web browser and click Always. Now links to Google Play will never open in the Play Store app.

Note that this isn't a security problem, whichever behaviour you choose. Web links can only open apps on the device if (1) the app specifically says it can understand/handle that kind of link; and (2) the app specifically says that it's safe to access it in that way from the web. The app does this using an intent filter marked with the browsable category.