pavan kumar
pavan kumar

Reputation: 408

why wouldn't either of document.location or window.location work?

This is the event handler I set up on a button:

$('.tabsTD').on('click', 'a.finalSave', (function () {
    var returnStatus= finalSave(this, location);

    if (returnStatus) {
        if ($(this).text() == "Save and Continue") {
            sessionStorage.carePlanReload = "true";
            sessionStorage.activeTab = $('#tabs').tabs("option", "active");
            window.event.returnValue = false;
            document.location.reload(false);
        }
        else if ($(this).text() == "Save and Close") {
            window.event.returnValue = false;
            document.location = "MemberHome.aspx";
            //setTimeout(function () { document.location = "MemberHome.aspx"; }, 500);
            //return false;
            //$('#aRedirectToHome')[0].click();
            return false;
        }
    } /*END if*/
}));

In the else if condition, I need to redirect to "memberhome.aspx", but nothing seems to work. I also tried adding an anchor tag, like:

<a href="MemberHome.aspx" id="aRedirectToHome" style="display:none;">RedirectToHome</a>

and then invoke a click on the anchor from else if, but it proved to be a failed attempt.

Please help.

Upvotes: 2

Views: 86

Answers (1)

Heri Hehe Setiawan
Heri Hehe Setiawan

Reputation: 1633

You need to either pass a new value to the href property as in:

window.location.href = "MemberHome.aspx";

or, using assign method as in:

window.location.assign("MemberHome.aspx");

Upvotes: 1

Related Questions