1
0

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.

target="_blank"での別タブ表示は、実は危険!?

Posted at

target="_blank"を用いて別タブ表示を実装しようと思い、色んな記事を見ていたのですが、
セキュリティ面とパフォーマンス面の2点で脆弱性があるとの記事を見かけたので、対策を実施。

HTML
<a href="リンク" target="_blank" rel="noopener noreferrer">

noopenerと、noreferrerの2つを加えてあげれば対策になるようです。

noopener を指定することで、リンク先からwindow.openerを使ってリンク元が参照できなくなる。さらに、リンク先とリンク元が別のものとして扱われるためパフォーマンスに対しての対策にもなる。

しかし、ブラウザによっては、noopenerがサポートされていないため、noopenerと合わせてnoreffererを指定するのが好ましい。

noreffererを指定することで、リンク先にリンク元のリンク情報が送られないようになるため、 noopenerと同じくリンク先からの参照ができなくなる。

らしいです。

参考サイト

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?