面倒だったのでポップアップを閉じる仕組みは未実装
html 1枚目
html
1<!DOCTYPE html>
2<html lang="ja">
3
4<head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Document</title>
8</head>
9
10<body>
11 <a href="2.html">2へ</a>
12 <script>
13 localStorage.setItem("key", "popup")
14 </script>
15</body>
16
17</html>
html 2枚目
html
1<!DOCTYPE html>
2<html lang="ja">
3
4<head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Document</title>
8 <style>
9 #popup {
10 width: 500px;
11 height: 500px;
12 position:absolute;
13 top:50%;
14 left:50%;
15 transform: translate(-50%,-50%);
16 display:none;
17 background-color: blue;
18 }
19 </style>
20</head>
21
22<body>
23<button id="button" type="button">
24 ポップアップ
25</button>
26<div id="popup"></div>
27<script>
28 const button = document.getElementById("button");
29 const popup = document.getElementById("popup");
30
31 button.addEventListener("click", () => {
32 popup.style.display = "block";
33 });
34
35 if(localStorage.getItem('key') === "popup") {
36 button.click();
37 localStorage.removeItem('key');
38 }
39
40</script>
41</body>
42
43</html>