Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

javascript - 使用CSS隐藏基于访问者国家/地区的div(Hide div based on country of visitor with CSS)

I want to display a responsive popup from visitors from certain countries.

(我想显示来自某些国家/地区的访问者的响应弹出窗口。)

I've used the plugin popup maker.

(我已经使用了插件弹出器。)

But, the script (from //freegeoip.net/json/) doesn't work on the popup maker theme built page or the product page (where I want it to appear).

(但是,该脚本(来自//freegeoip.net/json/)在弹出窗口主题构建页面或产品页面(我希望其显示的位置)上不起作用。)

So, my next step is to change the CSS so that it would at least display/not display (display: none !important;) to certain people.

(因此,我的下一步是更改CSS,以便至少对某些人显示/不显示(display:none!important;)。)

Now my question is what is the CSS code to achieve this?

(现在我的问题是要实现这一目标的CSS代码是什么?)

But, if you recommend to just use script how can I add this to override popup maker's code?

(但是,如果您建议仅使用脚本,那么如何添加它以覆盖弹出窗口制造商的代码?)

Also, my knowledge regarding CSS and JS is very limited

(另外,我对CSS和JS的了解非常有限)

<script>
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from Canada.
if (location.country_code === 'CA') {
  // Tell them about shipping to Canada.
  jQuery('#pum-5303.pum.pum-overlay.pum-theme-5292.pum-theme-default-theme.popmake-overlay.auto_open.click_open.pum-active').css('display','block');
  }
  }
  } );
</script>
  ask by Z5678 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...