Notes

Show a country selection popup and save choice in Cookie

Edit on GitHub

Web Development

Show popup on page load

jQuery

1<script>
2  $(document).ready(function(){
3    $("#myModal").modal('show');
4  });
5</script>
  • Save choice in cookie
1<img src="uk.png" alt="Continue to our UK site" onclick="setCountryCookie('UK')" />
1function setCountryCookie(country) {
2  document.cookie = `fppCountry=${country}`
3  countrySelector.hide();
4}

Redirect to the site they selected

1window.location.href = 'https://www.yoursite.com';

pass a value in header to the new site, check for it on the other site and if present add a cookie

window.location.search

1"myCountry=UK; myName=Amna; myAge=31"

becomes

1["fppCountry=UK", " myName=Amna", " myAge=31"]
1matchString('myName is Amna', 'myName') // true
2matchString('myName is Amna', 'thyName') // false