回答編集履歴

1

sample

2021/07/14 07:03

投稿

yambejp
yambejp

スコア116724

test CHANGED
@@ -7,3 +7,113 @@
7
7
 
8
8
 
9
9
  ずれを考えると上への追加はあまり現実的ではないかと思います。
10
+
11
+
12
+
13
+ # sample
14
+
15
+ ※追加用のテストAPI
16
+
17
+ //api.php
18
+
19
+ ```PHP
20
+
21
+ <?PHP
22
+
23
+ session_start();
24
+
25
+ $_SESSION["num"]=isset($_SESSION["num"])?$_SESSION["num"]+1:0;
26
+
27
+ print $_SESSION["num"];
28
+
29
+ ```
30
+
31
+ ```javascript
32
+
33
+ <style>
34
+
35
+ body{
36
+
37
+ margin:0;
38
+
39
+ }
40
+
41
+ .content:not(:first-child){
42
+
43
+ border-top:solid 0px;
44
+
45
+ }
46
+
47
+ .content{
48
+
49
+ height:200px;
50
+
51
+ border:solid 1px gray;
52
+
53
+ }
54
+
55
+ </style>
56
+
57
+ <script>
58
+
59
+ window.addEventListener('DOMContentLoaded', ()=>{
60
+
61
+ window.scroll({top:200});
62
+
63
+ });
64
+
65
+ window.addEventListener('scroll', ()=>{
66
+
67
+ const top=document.body.getBoundingClientRect().top;
68
+
69
+ if(top>=0){
70
+
71
+ fetch("api.php").then(res=>res.text()).then(txt=>{
72
+
73
+ document.body.insertBefore(Object.assign(document.createElement('div'),{className:'content',textContent:txt}),document.querySelector('.content'));
74
+
75
+ window.scroll({top:200});
76
+
77
+ flg=false;
78
+
79
+ });
80
+
81
+ }
82
+
83
+ });
84
+
85
+
86
+
87
+ </script>
88
+
89
+ <div class="content">
90
+
91
+ test
92
+
93
+ </div>
94
+
95
+ <div class="content">
96
+
97
+ test
98
+
99
+ </div>
100
+
101
+ <div class="content">
102
+
103
+ test
104
+
105
+ </div>
106
+
107
+ <div class="content">
108
+
109
+ test
110
+
111
+ </div>
112
+
113
+ <div class="content">
114
+
115
+ test
116
+
117
+ </div>
118
+
119
+ ```