Reputation: 18978
In my application there is a header menu. We have 5 menu items with same page url with different hash values such as
All the brand pages will be navigated to the same page (test.html) but with different hash.
Problem: when I click any of the links of brand page from HOME, the page automatically navigates to test.html and check for hash tag and loads item through ajax automatically.
But when I click any of the brand page links inside the brand page, the page is not refreshing.
Upvotes: 3
Views: 2227
Reputation: 4652
HTML:
<div id="menu">
<a href="#1">brand 1</a>
<a href="#2">brand 2</a>
</div>
JQ:
$(function() {
$('#menu a').click(function(e){
var url=$(this).attr('href');
window.location.href=url;// ## change url with hash
location.reload(); // ## reload page
e.preventDefault(); // ## prevent default click action
})
})
Upvotes: 5