Window.Location Not Working In IE?

孤人 提交于 2019-12-18 06:59:37

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/8809025/window-location-not-working-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!