简体   繁体   English

载入中的Introjs

[英]Introjs on load

I'm trying to implement an introduction tour for my site and came across Introjs . 我正在尝试为我的网站实施简介之旅,并且遇到了Introjs

All the examples show the tour launching upon button click, but I'm wondering if there's a way to launch the tour once the page loads without a button click. 所有示例都显示了在单击按钮时启动游览的过程,但是我想知道是否存在一种方法,可以在页面加载后不单击按钮的情况下启动游览。 Additionally, is it possible to have it launch only for the first time visiting? 另外,是否可以仅在首次访问时启动它?

I'm using angularjs to build my site, but am very much a novice . 我正在使用angularjs来构建我的网站,但是非常新手 Any suggestions are greatly appreciated! 任何建议,不胜感激!

Call introJs().start() on document ready event. 在文档就绪事件上调用introJs().start()

document.addEventListener("DOMContentLoaded", function() { 
  introJs().start();
});

The example on https://introjs.com/docs/getting-started/start uses the function call introJs().start() https://introjs.com/docs/getting-started/start上的示例使用函数调用introJs().start()

You only have to call the function whether on button click or document ready event. 无论是单击按钮还是准备文档事件,都只需调用该函数。

Coming to the second part of your question, the easiest solution would be to use localStorage . 关于您的问题的第二部分,最简单的解决方案是使用localStorage

Something like this, should do the trick. 这样的事情应该可以解决。

document.addEventListener("DOMContentLoaded", function() { 

    var hadTour = localStorage.getItem('hadTour');

    if(!hadTour){
            introJs().oncomplete(function() {
            localStorage.setItem('hadTour', true);
            }).onexit(function(){
            localStorage.setItem('hadTour', true);
            }).start();
    }

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM