I am working on a page and I am trying to reload the page on click and execute a function. This code works on Safara and Firefox, but it doesnt work on Chrome and im not sure about IE. Hoping someone can help me. Below is my code. Not sure if there is a better way of doing this.
Basically i am just create a URL and on click passing a data tag and then grabbing the data tag and assigning the category to the end of a url. Then i am executing the category url function that is called "#tomatoes". I have to reload the page because the function is already called earlier.
var categoryTitle = 'Tomatoes';
$('.activeCategory').html('<a href="#" class="activeCategory" data-caturl="#tomatoes">' + categoryTitle + '</a>');
//change the category dynamically if clicked from individual product page
$('.activeCategory').click(function(event) {
var caturl = $(this).children('a').data('caturl');
var newWindow = window.location.href="http://www.example.com/DEV/product-categories/example.php" + caturl;
if (newWindow === "http://www.example.com/DEV/product-categories/example.php" + caturl) {
location.reload();
$("caturl").click();
}
});