introJS(): dontShowAgain option is not showing in Javascript

91 Views Asked by At

These are included in my <head>:

  <link rel="stylesheet" href="https://unpkg.com/intro.js/minified/introjs.min.css">
  <script src="https://unpkg.com/intro.js/minified/intro.min.js"></script> 

In my javascript, I have implemented this code:

introJs().onexit(function() {
     document.getElementById("subdiv").scrollTo({
         top: 0,
         behavior: 'smooth'
     });
}).setOptions("dontShowAgain", true).start();

The tutorial animation shows, but for some reason the Don't show again option doesn't show. As a result the tutorial keeps opening everytime I run the page. How do I fix this?

1

There are 1 best solutions below

4
On

It looks like there's a small mistake in your code. The setOptions method takes an object as an argument, not a key and a value separately. Here's how you can fix it:

introJs().onexit(function() {
     document.getElementById("subdiv").scrollTo({
         top: 0,
         behavior: 'smooth'
     });
}).setOption("dontShowAgain", false).start();

Notice the change in setOptions where { dontShowAgain: true } is passed as an object.

This should resolve the issue, and the "Don't show again" option should work as expected.