Intro.js 2 pages then return to home

2019-07-04 17:23发布

I am using intro.js to create a small intro to my website. I want The tour to go from page 1(home)-2(another page) and then back to 1(home).

I have suscsesfully got it going from page 1-2 but am unsure about how to get it to return to page 1. I am very unskilled in javascript so it is probably an easy solution but the ones I have found online don't work.

Codedealing with page switching:

Home

<script type="text/javascript" src="js/intro.js"></script>
    <script type="text/javascript">
      document.getElementById('startButton').onclick = function() {
        introJs().setOption('doneLabel', 'Next page').start().oncomplete(function() {
          window.location.href = '../mtcook/mtcook.html?multipage=true';
        });
      };
    </script>

2nd Page(called mtcook):

 <script type="text/javascript" src="js/intro.js"></script>
    <script type="text/javascript">
      if (RegExp('multipage', 'gi').test(window.location.search)) {
        introJs().start();
      }
      </script>

1条回答
倾城 Initia
2楼-- · 2019-07-04 17:34

In the 2nd page couldn't you do what you did in the first page, so something like this:

 <script type="text/javascript" src="js/intro.js"></script>
    <script type="text/javascript">
      if (RegExp('multipage', 'gi').test(window.location.search)) {
        introJs().setOption('doneLabel','Next page').start().oncomplete(function() {
          window.location.href = '../mtcook/index.html' // or whatever your original page is
        });
      }
      </script>
查看更多
登录 后发表回答