Check if user is blocking 3rd party domain

匆匆过客 提交于 2019-12-05 13:15:45

Load an image from the domain you want to check against.

<img id="checkImg" src="https://www.google.com/images/srpr/logo3w.pngAAA" />

​ Just a regular image tag (notice the AAA at the end to make it not work). Then you can check the width of the image to see if it loaded or not.

if(document.getElementById('checkImg').clientWidth != 275)
    alert("Error")

The Google logo is 275px wide but the error image (in Chrome at least) is only 18px. So if the image is not 275px wide, I know it did not load.

Demo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!