使用 JS 代码屏蔽某个国家的访客
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script type="text/javascript">
function ipLookUp () {
$.ajax('http://ip-api.com/json')
.then(
function success(response) {
console.log(response.country);
if(response.country == 'China'){
window.location.href = "https://404.myshopify.com/";
}
},
function fail(data, status) {
}
);
}
ipLookUp();
</script>
本源码演示的是屏蔽中国。