質問編集履歴

2

コードブロックで囲む

2018/07/01 01:21

投稿

syagamisrash
syagamisrash

スコア9

test CHANGED
File without changes
test CHANGED
@@ -60,6 +60,8 @@
60
60
 
61
61
  ■main.htm
62
62
 
63
+ ```ここに言語を入力
64
+
63
65
  <!DOCTYPE html>
64
66
 
65
67
  <html>
@@ -76,7 +78,7 @@
76
78
 
77
79
  <body>
78
80
 
79
- <button id="executeSelf">execute(self)</button>
81
+ <button id="executeSelf">execute(self)</button>
80
82
 
81
83
  <button id="execute">execute(iframe)</button>
82
84
 
@@ -144,7 +146,7 @@
144
146
 
145
147
  ifr.onload = (e) =>{
146
148
 
147
- // ここのnewでエラーになる
149
+ // ここのnewでエラー
148
150
 
149
151
  var grid = ifr.contentWindow.document.getElementById("grid")
150
152
 
@@ -162,10 +164,14 @@
162
164
 
163
165
  </html>
164
166
 
167
+ ```
168
+
165
169
 
166
170
 
167
171
  ■blank.htm(iframeがsrcしてる)
168
172
 
173
+ ```ここに言語を入力
174
+
169
175
  <!DOCTYPE html>
170
176
 
171
177
  <html>
@@ -192,6 +198,8 @@
192
198
 
193
199
  </html>
194
200
 
201
+ ```
202
+
195
203
 
196
204
 
197
205
 

1

ソースコードを記載

2018/07/01 01:21

投稿

syagamisrash
syagamisrash

スコア9

test CHANGED
File without changes
test CHANGED
@@ -48,6 +48,154 @@
48
48
 
49
49
 
50
50
 
51
+ 全体像
52
+
53
+ ・main.htm (起動画面)
54
+
55
+ └handsontable.full.js (ライブラリ)
56
+
57
+ ・blank.htm (iframe)
58
+
59
+
60
+
61
+ ■main.htm
62
+
63
+ <!DOCTYPE html>
64
+
65
+ <html>
66
+
67
+ <head>
68
+
69
+ <meta charset="UTF-8" />
70
+
71
+ <title>Handsontable</title>
72
+
73
+ <link rel="stylesheet" href="handsontable.full.min.css" />
74
+
75
+ </head>
76
+
77
+ <body>
78
+
79
+ <button id="executeSelf">execute(self)</button>
80
+
81
+ <button id="execute">execute(iframe)</button>
82
+
83
+ <div id="grid">
84
+
85
+ </div>
86
+
87
+
88
+
89
+ <script src="handsontable.full.js"></script>
90
+
91
+ <script type="text/javascript">
92
+
93
+ document.getElementById("executeSelf").addEventListener("click", (e)=>{
94
+
95
+ var data = [
96
+
97
+ ['佐藤', 28],
98
+
99
+ ['鈴木', 19],
100
+
101
+ ['田中', 25]
102
+
103
+ ];
104
+
105
+
106
+
107
+ var grid = document.getElementById('grid');
108
+
109
+ new Handsontable(grid, {data: data});
110
+
111
+ })
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ document.getElementById("execute").addEventListener("click", (e)=>{
122
+
123
+ var data = [
124
+
125
+ ['佐藤', 28],
126
+
127
+ ['鈴木', 19],
128
+
129
+ ['田中', 25]
130
+
131
+ ];
132
+
133
+
134
+
135
+
136
+
137
+ var ifr = document.createElement("iframe")
138
+
139
+ ifr.src="blank.htm"
140
+
141
+
142
+
143
+ document.body.appendChild(ifr)
144
+
145
+ ifr.onload = (e) =>{
146
+
147
+ // ここのnewでエラーになる
148
+
149
+ var grid = ifr.contentWindow.document.getElementById("grid")
150
+
151
+ new Handsontable(grid, {data: data});
152
+
153
+ }
154
+
155
+ })
156
+
157
+
158
+
159
+ </script>
160
+
161
+ </body>
162
+
163
+ </html>
164
+
165
+
166
+
167
+ ■blank.htm(iframeがsrcしてる)
168
+
169
+ <!DOCTYPE html>
170
+
171
+ <html>
172
+
173
+ <head>
174
+
175
+ <meta charset="UTF-8" />
176
+
177
+ <title>Handsontable</title>
178
+
179
+ <link rel="stylesheet" href="handsontable.full.min.css" />
180
+
181
+ </head>
182
+
183
+ <body>
184
+
185
+ <span>ChildIframe</span>
186
+
187
+ <div id="grid">
188
+
189
+ </div>
190
+
191
+ </body>
192
+
193
+ </html>
194
+
195
+
196
+
197
+
198
+
51
199
  ### 試したこと
52
200
 
53
201
  ・callによるthisの書き換えでwindowを変更する