【问题标题】:Trigger an event using window.location.hash使用 window.location.hash 触发事件
【发布时间】:2017-06-18 03:08:24
【问题描述】:

我正在尝试通过使用 jquery/javascript window.location.hash 单击电子邮件中的外部链接来触发事件。不幸的是,该应用程序是用 angular 构建的,并且最初在 url 中有一个哈希 https://www.electricstudio.ph/#/

我什至尝试手动添加哈希,但该功能似乎没有触发。 https://www.electricstudio.ph/#/

function slideSignUp() {
    $('.header-form-container.signup').addClass('active');
}

$(document).ready(function() {
  if (window.location.hash == '#sign-up') {
        console.log('PING');
  }
});

【问题讨论】:

    标签: javascript jquery hash


    【解决方案1】:

    这通常对我有用:

    $(window).on('hashchange', function () {
        hashUrl = window.location.hash;
        if (hashUrl == "#sign-up") {
             console.log('PING');
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2010-10-02
      • 2013-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多