JavaScript load a page on button click

前端 未结 4 1123
忘了有多久
忘了有多久 2020-12-13 08:27

I am trying to do a very simple task here, I would like to be able to click a button on a page and have it take me to another page. I have tried window.location.href, and a

4条回答
  •  死守一世寂寞
    2020-12-13 08:57

    The answers here work to open the page in the same browser window/tab.

    However, I wanted the page to open in a new window/tab when they click a button. (tab/window decision depends on the user's browser setting)

    So here is how it worked to open the page in new tab/window:

    
    

    It doesn't have to be a button, you can use anywhere. Notice the _blank that is used to open in new tab/window.

提交回复
热议问题