I want to prevent users to navigate to URL´s that are not accessed through html element. Example:
Actually navigating on: myweb.com/news
And I want to navigate to myweb.com/news?article_id=10
by writing this in the browser navigation bar to avoid pressing any element (like <a>
).
When the user writes myweb.com/news?article_id=10
in the browser url, at the moment he presses enter, the browser should not allow him to navigate to the url.
I have tried:
//This wont work since jquery does not support it
$(window.location.href).on('change', function() {
//Here check if href contains '?'
alert("Not allowed");
});
//Neither works, doesnt do anything
$(window).on('change', function() {
alert("Not allowed");
});
References: there is something similar asked here On - window.location.hash - Change?, but im interested in the 'parameter' version of that question.