window.open(url) not opening new web page in the same tab

后端 未结 5 951
情歌与酒
情歌与酒 2021-01-24 08:24

window.open(\"index.php\"); does not open the new page in the same tab, it opens it in a new tab.

I tried window.open(\"index.php\",

5条回答
  •  青春惊慌失措
    2021-01-24 08:33

    As far as I know, window.location doesn't do this. The right method to do this is:

    document.location = 'url-you-want-to-open.ext';
    

    Best thing is to either include the full path (if it's on a different domain) or the absolute path if it's on the same domain. Only use relative path if the destination document is in the same folder.

    To add to this:

    window = speaks to the browser and its tabs

    document = speaks to the current document that's loaded in the browser / tab.

提交回复
热议问题