1
1

More than 1 year has passed since last update.

【JavaScript】ワンクリックで複数のページが開くリンクをブログに設置する方法

Last updated at Posted at 2022-06-29

知人の依頼で作成

超簡単です、非エンジニアでもhtmlをいじれればできると思います。

ソースコード

<p id="0629" style="color: #0000ee; text-decoration: underline;">ここクリックするとタブが開きます</p>

<script>
document.getElementById('0629').onclick = function(){
	window.open('https://www.google.com/?hl=ja');
	window.open('https://www.google.com/?hl=ja');
	window.open('https://www.google.com/?hl=ja');
	window.open('https://www.google.com/?hl=ja');
	return false;
}
</script>

指定したidのものをクリックしたさいに関数が発火するようにしています。

URLは仮でgoogleにしていますが、もちろん任意のもので大丈夫です。
例えばアクセスするとクーポンが取得できるようなページのリンクにすれば、ワンクリックで一括で大量のクーポンが取得できるような形にすることができますね。

window.open〜の部分をさらに増やすことも可能ですが、リクエスト先のサーバに負荷がかかるので、悪用厳禁です。

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