gpt4 book ai didi

javascript - iFrameResize 未定义 - 通过 CDN 加载并在 JS 文件中

转载 作者:行者123 更新时间:2023-12-01 00:48:34 24 4
gpt4 key购买 nike

我正在尝试利用iFrame Resizer根据内容(可以更改)调整同一域上 iFrame 的大小。

实例:https://bronzecc.co.uk/sunday-2nd-xi/

我收到一个 Uncaught ReferenceError: iFrameResize is not Defined 错误,但我检查了 iFrame,它们都通过 CDN 加载了正确的 JS,我还在该页面本身加载了正确的 JS。

用于初始化我正在使用的缩放器

var iframes = iFrameResize({log: true}, 'iframe');

MCE:https://gist.github.com/shivampaw/7b1dba5326706673a782d115358eca2a

window.html

<html>
<head>
<meta charset="UTF-8">
<title>Window</title>
</head>
<body>
<iframe src="iframe.html" style="width: 100%;" frameborder="0"></iframe>

<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.contentWindow.min.js"></script>
<script>
iframes = iFrameResize({}, 'iframe');
</script>
</body>
</html>

iframe.html

<html>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<title>102166</title>
</head>

<body>

<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>Match Time</th>
<th>Match Type</th>
<th>Home Team</th>
<th>Away Team</th>
</tr>
</thead>
<tbody>
<tr data-toggle="collapse" data-target="#details_3722786">
<td><i class="fa fa-plus" aria-hidden="true"></i></td>
<td>28/07/2019 14:00</td>
<td>League</td>
<td>Bronze CC</td>
<td>Wall CC</td>
</tr>
<tr class="collapse" id="details_3722786">
<td colspan="5" style="text-align: center;">
<p>
Ground: The Anson Ground B43 7BA<br />
Start Time: 14:00 </p>
</td>
</tr>
<tr data-toggle="collapse" data-target="#details_3722741">
<td><i class="fa fa-plus" aria-hidden="true"></i></td>
<td>04/08/2019 14:00</td>
<td>League</td>
<td>Burntwood St Matthew's CC</td>
<td>Bronze CC</td>
</tr>
<tr class="collapse" id="details_3722741">
<td colspan="5" style="text-align: center;">
<p>
Ground: The Riddings<br />
Start Time: 14:00 </p>
</td>
</tr>
<tr data-toggle="collapse" data-target="#details_3722745">
<td><i class="fa fa-plus" aria-hidden="true"></i></td>
<td>11/08/2019 14:00</td>
<td>League</td>
<td>Four Oaks Saints CC</td>
<td>Bronze CC</td>
</tr>
<tr class="collapse" id="details_3722745">
<td colspan="5" style="text-align: center;">
<p>
Ground: Coalville, Clarence Road, Four Oaks, Sutton Coldfield<br />
Start Time: 14:00 </p>
</td>
</tr>
<tr data-toggle="collapse" data-target="#details_3722710">
<td><i class="fa fa-plus" aria-hidden="true"></i></td>
<td>18/08/2019 14:00</td>
<td>League</td>
<td>Bronze CC</td>
<td>Wall CC</td>
</tr>
<tr class="collapse" id="details_3722710">
<td colspan="5" style="text-align: center;">
<p>
Ground: The Anson Ground B43 7BA<br />
Start Time: 14:00 </p>
</td>
</tr>
</tbody>
</table>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.min.js"></script>
</body>
</html>

无法弄清楚为什么它不起作用。

最佳答案

如果您查看第一个链接上提供的文档,它会显示 this section on usage :

看起来您已经切换了文件包含。包含 iFrame 的页面(即 window.html)应包含脚本 iframeResizer.min.js:

<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.min.js"></script>

作为 iFrame 内容的另一个页面(即 iframe.html)应包含其他脚本:

<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.contentWindow.min.js"></script>

切换它们,看看是否有效。

关于javascript - iFrameResize 未定义 - 通过 CDN 加载并在 JS 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57173292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com