There is a page on my ModX website that includes a couple of page jump links at the top for a few articles that are further down the page. This is the HTML for each of them:
<a class="jump" href="#article1">Article 1</a><br />
<a class="jump" href="#article2">Article 2</a><br />
<!-- and so on... -->
And before, the links were not working at all in IE 11 so I'm using the JavaScript here to check if the visitor is using IE and to perform the page jump:
var url = 'http://mywebsite/mywebpage';
$('a.jump').on('click', function(evt) {
evt.preventDefault();
var useragent = window.navigator.userAgent;
if (useragent.indexOf("Trident") > -1 || useragent.indexOf("Edge") > -1) { // IE, Edge
var href = $(this).attr('href');
window.location.assign(url + href);
} else { // anything else
var href = $(this).attr('href');
href = href.substring(1, href.length);
window.location.assign('other/url#' + href);
}
});
I'm not sure if this is the best way to check for IE, but for now it seems to be working.
This works just fine in Chrome and Firefox, but if I click on one of the page jumps in IE it jumps correctly, but after a second passes it redirects to the homepage of my website.
I am using ModX Revolution 2.5.7.
EDIT: Microsoft Edge seems to redirect straight to the homepage. EDIT 2: Updated JS code to check for Edge properly.