← Snippets - Script

Custom Disclaimers for Specific Links

Sometimes clients want certain links to have custom disclaimers, but they’re hard-coded so that custom disclaimer can’t be added just with the CMS. Luckily, adding a custom hard-coded disclaimer is surprisingly easy, especially on our Bootstrap 4 sites!

How To

First, inside of your banno-functions.js file, find the banno.site.setDisclaimers function. Within that, you will see a section for branded site disclaimers. We’re basically creating a copy of this to do the same thing, but with our custom disclaimer.

Below that piece, insert the code provided and update to include whatever links you need. In this example, we’re matching any links that go somewhere on facebook or twitter.

if (speedbump.match(/^https\:\/\/www\.facebook\.com/) || speedbump.match(/^https\:\/\/www\.twitter\.com/)) {
	var exitMsg = "test disclaimer, your text goes here!";
    var mobileExitMsg = "mobile test disclaimer, your text goes here! (can be the same as the desktop one too)";
}

Obviously if you only need one link, you can edit to remove the “or”! You can also comma-separate links if you prefer, I personally just prefer this method because it lets me see how many URLs are using my custom disclaimer. Note that, similar to when you whitelist a link in the normal disclaimer list, you will need to place a \ before each punctuation mark to avoid causing errors in the script.

Within the exitMsg and mobileExitMsg variables, you can put your custom disclaimer text. Feel free to use the pre-defined variables higher up in the file so that on desktop, your disclaimer says “Proceed” and on mobile, it says “OK” to reflect the js disclaimer on desktop vs. the js alert on mobile.

If your custom disclaimer was not requested to use any wording like that (“when you click Proceed”, “click OK to continue”), you will most likely want to define exitMsg and mobileExitMsg as the same thing to make sure they both show up correctly.

If this is completed correctly, all you need to do is build your files and upload, and the new disclaimer should show instead of the normal one!

Tags: bs2, bs3, bs4 scripts, js, javascript, disclaimers