Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Take away cookie? #139

Open
LisaNewcomb opened this issue Dec 12, 2017 · 5 comments
Open

Take away cookie? #139

LisaNewcomb opened this issue Dec 12, 2017 · 5 comments

Comments

@LisaNewcomb
Copy link

Hi, is there a way to make this appear every time a person visits the site?

@LisaNewcomb
Copy link
Author

Or, I see that may be an option in the code but what would I replace it with? Say, 1 hour, for example.

@shrink
Copy link

shrink commented Dec 12, 2017

setCookie: function(name, val, exdays) {
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = name + "=" + val + "; " + expires + "; path=/";
},

The expiration cookie value is set in days but it doesn't need to be a whole number, so for 1-hour expiry you can set the value to 1/24 (1 day divided by 24 hours), e.g:

<script type="text/javascript">
  var _bftn_options = {
    viewCookieExpires: 1/24
  }
</script>
<script src="https://widget.battleforthenet.com/widget.js" async></script>

And to cause the pop-up to display on every page load you could set the value to 0:

<script type="text/javascript">
  var _bftn_options = {
    viewCookieExpires: 0
  }
</script>
<script src="https://widget.battleforthenet.com/widget.js" async></script>

@LisaNewcomb
Copy link
Author

Ok, so this would work:

<script>var _bftn_options = { theme: 'stop' ; viewcookieexpires: 0 };</script><script src="https://widget.battleforthenet.com/widget.js" async></script>

@shrink
Copy link

shrink commented Dec 12, 2017

Variable names are case-sensitive, so you'll need to ensure it matches viewCookieExpires exactly. The following should work with no expiry and the stop theme:

<script type="text/javascript">
  var _bftn_options = {
    theme: 'stop',
    viewCookieExpires: 0
  }
</script>
<script src="https://widget.battleforthenet.com/widget.js" async></script>

You can use jsfiddle.net to test out Javascript (and HTML, and CSS) if you're not sure if something will work or not, before pushing it live on your website. After opening jsfiddle.net, paste the above code into the HTML box (at the top left) and then click "Run" (above the HTML box) and you'll see in the bottom right the result of your code.

I hope that helps! :)

@LisaNewcomb
Copy link
Author

LisaNewcomb commented Dec 12, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants