I am trying to make use of iFrame Resizer to resize an iFrame on the same domain based on it's content (which can change).
Live Example: https://bronzecc.co.uk/sunday-2nd-xi/
I am getting an Uncaught ReferenceError: iFrameResize is not defined
error but I have checked the iFrames and they all load the correct JS via CDN and I also load the correct JS on that page itself.
For initialising the resizer I am using
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>
Can't figure out why it isn't working.
If you look at the documentation you provided on the first link, it shows this section on usage:
It looks like you have switched the file includes. The page holding the iFrame
(i.e. window.html
)should contain the script iframeResizer.min.js
:
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.min.js"></script>
The other page which is the content of the iFrame
(i.e. iframe.html
)should contain the other script:
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.contentWindow.min.js"></script>
Switch them around and see if it works.