alert창을 SweetAlert2를 사용해서 바꾸기 채택완료
</p>
<p>// 출석 시간 체크
if (date("H:i:s") < $att_start_time || date("H:i:s") > $att_end_time) {
alert("출석 시간이 아닙니다.");
exit;
}</p>
<p>
</p>
<p>// 출석 시간 체크
if (date("H:i:s") < $att_start_time || date("H:i:s") > $att_end_time) {</p>
<pre class="language-php">
<code class="language-php"><span class="token operator"><</span>script<span class="token operator">></span>
Swal<span class="token punctuation">.</span><span class="token function">fire</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
text<span class="token punctuation">:</span> <span class="token double-quoted-string string">"출석 시간이 아닙니다."</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>ok<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span>window<span class="token punctuation">.</span>history<span class="token punctuation">.</span><span class="token function">back</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator"><</span><span class="token operator">/</span>script<span class="token operator">></span>
</code>}
</pre>
<p>
위와 같이 변경했는데 실제 실행 시 페이지 오류가 발생하네요 ㅠㅠ
어느부분이 문제인지 확인해주시면 감사하겠습니다
답변 5개
cdn이 잘못된것 같은데요.
사용중이신건 1인것 같고
2는
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
이걸로 바꿔보세요,
답변에 대한 댓글 2개
만약 그래도 오류 뜬다면 php 변수 오류일겁니다.
댓글을 작성하려면 로그인이 필요합니다.
<link href="//cdn.jsdelivr.net/npm/@sweetalert2/theme-dark@4/dark.css" rel="stylesheet">
<script src="//cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.js"></script>
이걸 먼저 실행하고 해 보세요.
저는 sweetalert.js이거 하나만 사용합니다.
댓글을 작성하려면 로그인이 필요합니다.
전체 흐름은 몰겠지만
Swal.fire({
text: "출석 시간이 아닙니다."
}).then((ok) => {window.history.back()});
이부분을 바꿔보세용.
1안.
</p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>swal.fire({ </code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> text: "출석 시간이 아닙니다." </code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>}).then((ok) => {</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> if (ok) {</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> window.history.back()</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> }</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>});</code></span></span></p>
<p>
2안.(2버전기준)
</span></font></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>swal.fire({ </code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> text: "출석 시간이 아닙니다." </code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>}).then((ok) => {</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> if (ok.isConfirmed) {</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> window.history.back();</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> }</code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>});</code></span></span></p>
<p>
3안 (간단버젼)
</p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>swal.fire({ </code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> text: "출석 시간이 아닙니다." </code></span></span></p>
<p><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>}).then(() => {</code></span></span><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code> window.history.back() </code></span></span><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>}</code></span></span><span style="font-size:10pt;"><span style="font-family:맑은 고딕;"><code>);</code></span></span></p>
<p><font face="monospace"><span style="font-size: 13.3333px;">
댓글을 작성하려면 로그인이 필요합니다.
</p>
<pre>
<code><?
// 출석 시간 체크
if (date("H:i:s") < $att_start_time || date("H:i:s") > $att_end_time) {
?>
<script>
Swal.fire({
text: "출석 시간이 아닙니다."
}).then((ok) => {window.history.back()});
</script>
<?}?>
</code></pre>
<p>
php와 js를 구분해주셔야할 것 같습니다.
<??> 표기나 echo 로 감싸주시면 될 것 같습니다.
답변에 대한 댓글 1개
페이지가 작동하지 않습니다 라고 나오네요 ㅠ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
-> <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
변경했는데도 증상은 동일합니다 ㅠ