Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

javascript - Window.Location Not Working In IE?

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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...