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

HTMLのリンクで別ウィンドウを開く

Last updated at Posted at 2020-11-30

はじめに

タイトルについて記事にしました。
この記事で得る内容は以下の通りです。

・ HTML(aタグ)の基礎知識が増える
・ HTMLのリンクをクリック時、脆弱性を防ぎつつ、別ウィンドウを開く方法

リンクの仕様について

リンクはaタグで生成しますが、特に何も指定がない場合は、リンクにアクセスした同じウィンドウで開きます

HTMLのリンクで別ウィンドウを開く方法

別ウィンドウでリンクを開きたい場合は、下記の様にaタグにtarget="_blank"属性を追加します

index.haml
.sns
  %a.qiita(href="https://qiita.com/s79ns" target="_blank")
    %i.fas.fa-search

しかし、target="_blank"だけでは、Tabnabbing(タブナビング)と呼ばれる脆弱性を突かれる可能性があるそうです。

・ Tabnabbing(タブナビング)

target="_blank"で開かれたウィンドウから、もとのウィンドウの操作ができてしまう脆弱性
 これを防止するにはtarget=_"blank"と合わせてrel="noopener"属性を追加します

index.haml
.sns
  %a.qiita(href="https://qiita.com/s79ns" target="_blank" rel="noopener noreferrer")
    %i.fas.fa-search
0
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
0
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?