回答編集履歴

2

調整

2023/05/30 01:26

投稿

yambejp
yambejp

スコア115010

test CHANGED
@@ -18,3 +18,13 @@
18
18
 
19
19
  ```
20
20
  そもそもscriptでnoscriptを記載することは意味のない処理なので深く考えても仕方ないと思います。
21
+ 同様にnoscript内のscriptも実行されます
22
+ ```javascript
23
+ window.onload=function(){
24
+ const noscript = document.createElement("noscript");
25
+ const script = document.createElement("script");
26
+ script.textContent='alert("test")';
27
+ noscript.appendChild(script);
28
+ document.body.appendChild(noscript);
29
+ }
30
+ ```

1

調整

2023/05/30 01:21

投稿

yambejp
yambejp

スコア115010

test CHANGED
@@ -2,11 +2,19 @@
2
2
  そういうものだと理解するしか無いでしょう
3
3
  文字列で処理すれば大丈夫です。
4
4
  ```javascript
5
+ <script>
5
6
  window.onload=function(){
6
7
  const noscript = document.createElement("noscript");
7
8
  noscript.innerHTML=`<meta http-equiv="refresh" content="1;URL='https://example.com/'">`;
8
9
  document.body.appendChild(noscript);
9
10
  document.body.insertAdjacentHTML('beforeend',`<noscript><meta http-equiv="refresh" content="1;URL='https://example.com/'"></noscript>`);
10
11
  }
12
+
13
+ </script>
14
+ test
15
+ <noscript>
16
+ <meta http-equiv="refresh" content="1;URL='https://example.com/'">
17
+ </noscript>
18
+
11
19
  ```
12
20
  そもそもscriptでnoscriptを記載することは意味のない処理なので深く考えても仕方ないと思います。