Can someone help me with a puzzling issue I can't seem to solve?
I am trying to achieve the following:
Whenever a link is clicked (for example: mysite.com/blog/blog-article.html), I want to save the href of that link to a variable. Then, in JavaScript, redirect it to a different URL (the main category – mysite.com/blog). All pages are dynamically loaded.
In this mysite.com/blog page, there is an "a" element without a href. I would like to assign the saved blocked URL (stored in a variable) to this "a" element.
$('#go-to-next').attr('href', goToUrl);
Everything seems to be working fine, but after a delay, I want the click event to be triggered.
setTimeout(function(){
$('#go-to-next').click();
}, 500);
Unfortunately, this is not functioning as expected. Does anyone have any insights into what might be causing this issue? Interestingly, when I run the timeout script in Firebug, it works perfectly. It appears to be related to .on(), even though I can change the href without any errors.