Javascript location.href crash on Explorer 11

Today, I noticed this issue in IE11.

A simple JavaScript redirect (made via location.href = 'newhost...';) causes the browser to crash.

Read More

Does anyone have any idea how can this be fixed?

If it helps this happened using ContactForm7 on wordpress using this method: http://contactform7.com/redirecting-to-another-url-after-submissions/

Related posts

Leave a Reply

3 comments

  1. Internet Explorer doesn’t always play nice with location.href or window.location.href in javascript. i.e. more so the href function…

    Try using:

    window.location.assign("newhost.."); // or
    window.location = "newhost..";
    

  2. There is a solution to this problem in a WordPress forums post here: https://wordpress.org/support/topic/redirection-crashes-ie-11-perfect-for-all-others

    KookRoss says:

    I found a solution to this, its an ugly one but it does get around the
    issue for me.

    on_sent_ok:
    "$("#post-440").empty();window.location.replace('https://www.url.com.au/thank-you/');"
    

    Where post-440 is the ID of the div which surrounds the form. Put
    simply your post led me to the belief that IE is somehow passing that
    form again before doing the redirection, this uses jQuery to clear
    that entire page of content (including the form) before doing the
    redirection.

    Its a hack way to get around the IE issue but so far its working in
    all browsers for me including IE11.

  3. If you still get this error even using Assign in IE 11 when redirect from an event, you can use:

    setTimeout(function ()
    {
       window.location.assign("newhost...");
    }, 100);
    

    To get around the problem