仅在特定国家/地区显示链接
答
您可以阅读导航器进行本地化并更改html元素的属性。
Using language | NavigatorLanguage.language
使用位置| Navigator.geolocation(不能发布2个链接)
“developer.mozilla.org/en-US/docs/Web/API/Navigator/geolocation”
const changeLink = document.querySelector(".theLinkThatChanges");
if (window.navigator.language == 'EN') {
changeLink.setAttribute("src", "https://www.englishlink.here");
}
注:我加了我自己的答案后点击通过那些没有明确答案的“重复”中的4个。
可能重复的[如何使用JavaScript获取浏览器语言](http://*.com/questions/8199760/how-to-get-the-browser-language-using-javascript) –
可能是重复的[如何使用JavaScript地理位置获取访问者的位置(即国家)](http://*.com/questions/3489460/how-to-get-visitors-location-ie-country-using-javascript-geolocation)。 – Chad