teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

エラーメッセージの追記です

2020/11/17 13:11

投稿

tendo
tendo

スコア3

title CHANGED
File without changes
body CHANGED
@@ -98,4 +98,8 @@
98
98
  //命令を書く
99
99
  window.alert('Hello World!');
100
100
  });
101
- ```
101
+ ```
102
+
103
+ ##追記
104
+ ##Access to internal resource at 'file:///C:/Users/User/Documents/javascript_seito/site.webmanifest' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
105
+ となっています

1

コードを書きました

2020/11/17 13:11

投稿

tendo
tendo

スコア3

title CHANGED
File without changes
body CHANGED
@@ -3,4 +3,99 @@
3
3
  ####エラーはこのようになっています。__****__Access to internal resource at 'file:///C:/Users/User/Documents/javascript_seito/site.webmanifest' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
4
4
  __****__
5
5
  ###原因を確かめるために参考にしたコードをそのまま実行してもJavaScriptが実行されませんでした。  console.log('hello')のみでも実行されなかったのでコード以外の原因があるようです。    先週金曜日から解決法を見いだせていませんので力- リスト---をお貸しください。
6
- [リンク内容](https://github.com/seito-developer/js-tutorial)
6
+ [リンク内容](https://github.com/seito-developer/js-tutorial)
7
+
8
+ ```
9
+ <!doctype html>
10
+ <html class="no-js" lang="">
11
+
12
+ <head>
13
+ <meta charset="utf-8">
14
+ <title></title>
15
+ <meta name="description" content="">
16
+ <meta name="viewport" content="width=device-width, initial-scale=1">
17
+
18
+ <link rel="manifest" href="site.webmanifest">
19
+ <link rel="apple-touch-icon" href="icon.png">
20
+ <!-- Place favicon.ico in the root directory -->
21
+
22
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
23
+
24
+ <meta name="theme-color" content="#fafafa">
25
+ </head>
26
+
27
+ <body>
28
+
29
+ <div class="container">
30
+
31
+ <div id="js-question" class="mt-3 alert alert-primary" role="alert">
32
+ A simple primary alert—check it out!
33
+ </div>
34
+
35
+ <div class="d-flex justify-content-center">
36
+ <button type="button" class="btn btn-primary">Primary</button>
37
+ <button type="button" class="ml-1 btn btn-primary">Primary</button>
38
+ <button type="button" class="ml-1 btn btn-primary">Primary</button>
39
+ <button type="button" class="ml-1 btn btn-primary">Primary</button>
40
+ </div>
41
+
42
+ </div>
43
+
44
+ <script src="index.js"></script>
45
+
46
+ </body>
47
+
48
+ </html>
49
+ ```
50
+
51
+
52
+ ```javascript
53
+
54
+ let unko = 'Hello World!';
55
+
56
+
57
+ const bigUnko = 'He..Hell...Hello World!';
58
+
59
+
60
+ const inoki = ['いーち','にーい','さーん','ダーー!!'];
61
+
62
+
63
+ let index = 0;
64
+ while(index < inoki.length){ //=4
65
+ // 繰り返したい命令
66
+ console.log(inoki[index]);
67
+ index++; //index = 5
68
+ }
69
+
70
+ //if / else
71
+ if(inoki.length > 5){
72
+ console.log('ボンバイエ!');
73
+ } else {
74
+ console.log('ボンバ...!');
75
+ }
76
+
77
+ //関数
78
+ const test = (arg) => {
79
+ //ここに実行したい命令を書く
80
+ if(inoki.length > arg){
81
+ console.log('ボンバイエ!');
82
+ } else {
83
+ console.log('ボンバ...!');
84
+ }
85
+ };
86
+
87
+ //オブジェクト
88
+ const unko2 = {
89
+ color: 'pink',
90
+ size: 'large',
91
+ purfume: 'mint',
92
+ goToilet: () => {
93
+ console.log('Hello world!');
94
+ }
95
+ };
96
+
97
+ document.getElementsByTagName('button')[0].addEventListener('click', ()=> {
98
+ //命令を書く
99
+ window.alert('Hello World!');
100
+ });
101
+ ```