簡體   English   中英

使用基於 IP 地址的 JavaScript 隱藏元素

[英]Hide element with JavaScript based in IP-Address

我試圖隱藏基於 IP 地址的元素。

使用這個腳本,我可以寫出 DOM 中的 IP 地址:

<script type="text/javascript" src="https://l2.io/ip.js?var=userip"></script>
<script type="text/javascript">document.write("Your IP is :", userip)</script>

我如何根據特定的 IP 地址將其定位為刪除下面的元素?

只需使用准備好的文件並檢查ip。 如果它符合條件做你的東西

    var ip=['123.123.123','111.111.11']
     $(document).ready(function () {
if(ip.indexOf(userip)!=-1)
{ your  code here
}
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM