0

I have a question about opening a URL in current window by using window.open. It is a master-page in SharePoint 2013

The condition is :

If current window is the site AAA, user opens the site BBB in this current window.

If current window is not the site AAA, user opens the site BBB in a new window.

The line window.open("http://siteBBB","_blank"); works

but the line window.open("http://siteBBB","_self"); does not work. It always the same page after the script running

if(window.location.href.indexOf("http://siteAAA") > -1)
{       

    window.open("http://siteBBB","_self");

    } else 
    {window.open("http://siteBBB","_blank");
    }
0

Try

if(window.location.href.indexOf("http://siteAAA") > -1) {            
    window.location.href = "http://siteBBB";
} else {
    window.open("http://siteBBB","_blank");
}
  • I tried this, the same result like window.open. I added a alert after window.open(), the alert displays when script running, and the page refresh. But always the same page, it does not change – AnnaCICI May 27 '15 at 6:23
  • Maybe I should force a script re-execute for window.open? – AnnaCICI May 27 '15 at 7:28
  • Which browser you are testing with? Also try window.location.assign("http://siteBBB"); and window.location.replace("http://siteBBB") – Amal Hashim May 27 '15 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.