admin管理员组文章数量:1429102
Hello I just start learning with javascript and I would like to know how to make multipage intro by using intro.js
function beginer() {
var intro = introJs();
intro.setOptions({
steps: [
{
element: '#beginer1',
intro: "This is a <b>bold</b> tooltip."
},
{
element: '#beginer2',
intro: "Ok, <i>wasn't</i> that fun?",
position: 'bottom'
},
]
});
intro.setOptions({
'showStepNumbers': false
});
intro.start();
}
Hello I just start learning with javascript and I would like to know how to make multipage intro by using intro.js
function beginer() {
var intro = introJs();
intro.setOptions({
steps: [
{
element: '#beginer1',
intro: "This is a <b>bold</b> tooltip."
},
{
element: '#beginer2',
intro: "Ok, <i>wasn't</i> that fun?",
position: 'bottom'
},
]
});
intro.setOptions({
'showStepNumbers': false
});
intro.start();
}
Share
Improve this question
asked Oct 15, 2016 at 7:14
ThidaThida
711 silver badge3 bronze badges
1
- Possible duplicate of Can I use multiple intro.js with more than 2 pages? – Carl Commented Oct 18, 2016 at 22:03
1 Answer
Reset to default 3It is as simple as bining the options given in the multipage
and programmatic
examples in the repo. The multipage example is here
All you got to do is add an onComplete
listener on the first page like so:
function beginer() {
var intro = introJs();
intro.setOptions({
showStepNumbers: false,
doneLabel: "Next page",
steps: [
{
element: '#beginer1',
intro: "This is a <b>bold</b> tooltip."
},
{
element: '#beginer2',
intro: "Ok, <i>wasn't</i> that fun?",
position: 'bottom'
},
]
});
intro.start().onplete(function() {
window.location.href = 'second.html?multipage=true';
});
}
I have sanitized the setOptions
call in your function and bined all the options there. So that you don't have to do setOptions
multiple doneLabel
param. I guess, it triggers the onplete
method which is defined after intro.start()
. It redirects to the next page which in my case is second.html
. Remember to pass the param multipage=true
.
second.html
is a regular HTML file but you need to start the introJs
function to make the whole transition mulitpage. All you do is:
<script type="text/javascript">
if (RegExp('multipage', 'gi').test(window.location.search)) {
introJs().start();
}
</script>
This in essence triggers the introJs().start()
function after it finds the word multipage
in the url or href in your browser address bar. Remember we called second.html
like second.html?multipage=true
. This just starts another intro instance on the second page. Now you can define the options here in form of JSON if you want or just use the data-step
attributes on DOM as defined in the docs.
Hope it gets you started in the right direction.
本文标签: javascriptHow can I make multipage intro by using Introjs programmaticStack Overflow
版权声明:本文标题:javascript - How can I make multipage intro by using Intro.js programmatic - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745416781a2657720.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论