April 27, 2020
Estimated Post Reading Time ~

window.location.href is not working while clicking on hyper link in IE

I was trying to redirect to a page while clicking on a hyperlink with JQuery Ajax and javascript windows.location.href

<a id="signout" href="">signOut<a/>

<script>
$("#signout").click(function(){

$.ajax({
type : "POST",
async: false,
url : "/services/logout",
success : function() {
window.location="/content/test/test.html";
},
error : function() {
window.location="/content/test/test.html";
}
});
} );
</script>

This is working perfectly in both Firefox and Chrome but it is not working in IE.

In IE while redirecting the URL is stripped off to /content/test/(test.html got removed while performing the redirect)

The issue can be fixed as below by adding # in the href attribute.

<a id="signout" href="#">signOut<a/>


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.