3
3

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 5 years have passed since last update.

iframe内のリンクを使いたくない時

Last updated at Posted at 2019-03-11

2020/08/17
instawidgetがサービス終了した上に、代替サービスでよく使われてる(であろう)instawindowではiframeを採用してないのでこの記事自体要らなくなってしまった。。
https://insta-window-tool.web.app/

ただ、iframe内のリンクで困ったときのために残します。

instawidgetをサイトに埋め込み時、リンク先を自由に設定することができない
(instawidgetの記事URLに飛んでしまう)

自由なURLを設定したかったのでiframeのクリックイベントをjsで制御しようとしたけどレイヤーの関係なのかうまく制御できず、、

CSSでiframe内のクリックを無効にできるのでそっちでできた。

<script src="https://instawidget.net/js/instawidget.js?u=ce6e9e4a15482922f195a1fe83cda9ecb592598bf296f3cd907e3d67fc24b0ee&width=300px"></script>

<a href="http://google.com" target="blank" id="hoge">
<script src="https://instawidget.net/js/instawidget.js?u=ce6e9e4a15482922f195a1fe83cda9ecb592598bf296f3cd907e3d67fc24b0ee&width=300px"></script>
</a>
<style>
# hoge {
	display:block;
}
# hoge iframe{
	pointer-events: none;
}
</style>

これでできる。

3
3
2

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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?