Window.Location Not Working In IE?
Asked Answered
P

1

4

I have been trying to figure this out all afternoon, but have given up and now turning to you clever people to help :)

I have the following Jquery/Javascript function, which is working fine in Chrome - BUT in IE nothing happens?

    $(".btnsubmitpost").click(function () {
    var topicid = $(this).attr('rel');
    var sbody = tinyMCE.get('txtPost').getContent();
    $('.topicpostlistnewpost').remove();
    $('.postsuccess').show();
    $.post("/myurl/" + topicid + ".aspx",
           { "postcontent": sbody },
            function (data) {
                var returnUrl = $("value", data).text();
                window.location.href = returnUrl;
                return false;
            });
    return false;
});

I have tried window.location, window.location.href both with full urls and absolute Urls but IE just doesn't like it? Any ideas?

The function just gets a Url back from a post, and is supposed to redirect the user to the Url. But like I say, works in Chrome fine just not in IE (Tried IE8 and IE9)

Pruitt answered 10/1, 2012 at 19:8 Comment(5)
Can you debug and find in IE what does returnUrl contain?Beekeeping
don't return false from your inner function.Anitraaniweta
Check this link it may help: #4819368Noelianoell
returnUrl is either returning /mypage.aspx?p=12 or mydomain.com/mypage.aspx?p=12#comment12? As I say, its working in Chrome and its not the 'returnUrl'. I shall try and remove the return false from the inner function and see if that sorts itPruitt
nope removing the return false makes no difference, I actually completely removed it and tried event.preventDefault() but still it just doesn't redirect - Checked url in debugger and its fine?Pruitt
P
3

Just for anyone having the same issue, the problem was because the window.location was inside the Ajax post method.

Just replace the window.location with a function() that then calls the window.location or do it after the Ajax call completely.

Pruitt answered 3/7, 2012 at 18:40 Comment(2)
Calling the window.location.href in success of ajax post makes the same issue ??Bawd
Replacing the window.location with a function didn't work for me. Any other alternative, other than placing window.location after ajax callProselytism

© 2022 - 2024 — McMap. All rights reserved.