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

后端 未结 5 847
情歌与酒
情歌与酒 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.

    0 讨论(0)
  • 2021-01-24 08:37

    Instead of window.open you should use window.location = "http://...."

    0 讨论(0)
  • 2021-01-24 08:47

    window.location is the function/property you should look at.

    0 讨论(0)
  • 2021-01-24 08:54

    window.open will open in new tab if action is synchronous and invoked by user. If you remove async: false from ajax options (and this method is invoked by user for example by clicking a button), then new window will open instead of new tab. For simple navigation set window.location.href

    0 讨论(0)
  • 2021-01-24 08:56

    The window.open function opens a new window(or tab). The window.location changes the url the current tab.

    0 讨论(0)
提交回复
热议问题