我正在尝试使用 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');
}
});
最佳答案
这通常对我有用:
$(window).on('hashchange', function () {
hashUrl = window.location.hash;
if (hashUrl == "#sign-up") {
console.log('PING');
}
});
关于javascript - 使用 window.location.hash 触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41978607/