必要なものが揃うのを待ってから始めるようにするのはいかがでしょうか。
javascript
1function start() {
2 if (window.$ && window.$.ui) {
3 $(document).ready(function(){
4 func_test();
5 });
6 } else {
7 setTimeout(start, 50);
8 }
9}
10start();
追記:また、親ウインドウのスクリプトを以下のように修正してください。
javascript
1$(function() {
2 $('#frame').on('load', function() {
3 var iframe = this;
4 // iframe の window
5 var iframeWindow = iframe.contentWindow;
6 // iframe の document
7 var iframeDocument = iframeWindow.document;
8 // iframe の document.head
9 var iframeHead = iframeDocument.head;
10
11 // iframeDocument を使って
12 // <link rel="stylesheet" href="./resources/assets/css/jquery-ui.min.css">
13 // をつくって iframeHead に追加する
14 var link = iframeDocument.createElement('link');
15 link.setAttribute('rel', 'stylesheet');
16 link.setAttribute('href', './resources/assets/css/jquery-ui.min.css');
17 iframeHead.appendChild(link);
18
19 // iframeDocument を使って
20 // <script src="./resources/assets/js/jquery.js">
21 // をつくって iframeHead に追加する
22 var script1 = iframeDocument.createElement('script');
23 script1.setAttribute('src', './resources/assets/js/jquery.js');
24 iframeHead.appendChild(script1);
25
26 // iframeDocument を使って
27 // <script src="./resources/assets/js/jquery-ui.min.js">
28 // をつくって iframeHead に追加する
29 var script2 = iframeDocument.createElement('script');
30 script2.setAttribute('src', './resources/assets/js/jquery-ui.min.js');
31 iframeHead.appendChild(script2);
32
33 })
34});
iframe 内の link や script の要素を生成するのに、親ウインドウにある jQuery($)や document をつかわないのがポイントです。親の document で生成された要素を iframe の中に持っていっても、データを読み込んでくれません。iframe 内の要素は iframe の document、つまり iframe.contentWindow.document で生成します。
動くサンプルを作りました。下の方にある loadJquery が親ウインドウのスクリプトにあたります。
https://codepen.io/hoo-chan/pen/PRowQj
IE以外のブラウザでご覧ください。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/08 05:08
退会済みユーザー
2018/03/09 03:17
2018/03/09 06:35
退会済みユーザー
2018/03/09 07:00 編集
2018/03/11 04:22
退会済みユーザー
2018/03/11 05:46
2018/03/12 03:55
退会済みユーザー
2018/03/13 14:40
2018/03/16 04:19
退会済みユーザー
2018/03/17 11:28 編集
2018/03/19 02:17