javascript - 跳房子 on 关闭游览功能

标签 javascript hopscotch

我正在使用 Hopscotch 创建游览,我希望为用户创建在点击页面后进行或退出页面游览的功能。

我正在尝试创建一个 onClose 函数,但我遇到了困难。

var tour = {
   id: "businesstour-hopscotch",
   steps: [
{
  title: "Welcome",
  content: "This is the new business profile page, click next to have a quick tour.",
  target: document.querySelector('#companyname'),
  placement: "right",
  xOffset: -380,
  yOffset: 52,
  onClose: function() {
    window.location = '/';
  }
},

等等,但它不起作用。也没有显示结束游览的按钮。 任何想法都会有帮助!

最佳答案

根据我对文档的理解,onClose 定义是一个“Tour Option”,应该像这样声明,而不是在步骤内声明:

var tour = {
   id: "businesstour-hopscotch",
   onClose: function() {
       window.location = '/';
   },
   steps: [{
       title: "Welcome",
       content: "This is the new business profile page, click next to have a quick tour.",
       target: document.querySelector('#companyname'),
       placement: "right",
       xOffset: -380,
       yOffset: 52
     }]
};

我正在像这样初始化我的,这适用于用户单击游览右上角的“x”。但是,当用户单击导览最后一步的“完成”按钮时,我没有看到此事件被触发。

关于javascript - 跳房子 on 关闭游览功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36705875/

相关文章:

javascript - jQuery Force 为 iframe 设置 src 属性

javascript - 将 async/await 与 for in 循环一起使用

javascript - Nodejs 中的命令行 stdout 到数组

jquery - 动态生成内容上的跳房子之旅

javascript - 从 JSON 属性中删除双引号

javascript - 如何找到 typedArray 的类型?

javascript - JQuery 仅选择所选元素内的元素