25
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

window.location.hrefで別タブでリンクを開く方法

Last updated at Posted at 2020-06-25

window.location.hrefを使用すると、外部URLへ遷移させることができます。

window.location.href = 'https://qiita.com'

上記では、同一のタブで開くので、別タブで外部サイトを開かせる場合はwindow.open()を使います。

window.open()で外部URLを開く

const url = 'https://qiita.com'
window.open(url, '_blank')

上記のコードで、別タブで外部URLを開くことが可能です。

25
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?