I am trying to use the iFrameResizer package on a parent site and embed a basic react page via an iframe. To the parents site's index.html I've added the following code:
<iframe frameborder="0" id="sizetracker" src="http://localhost:3001" width="100%"
style="position: fixed; z-index: 1000; bottom: 0; right: 0"></iframe>
<script src="https://cdn.jsdelivr.net/npm/iframe-resizer@4.2.11/index.min.js"></script>
<script>
window.iFrameResize({ log: true }, '#sizetracker') // error thrown here
</script>
I'm using a cdn to add the package. I've tried the CDN from unpkg (via https://unpkg.com/iframe-resizer@4.3.2/index.js) as well as the url in the src attribute above that I got from js-delivr.
Two errors are thrown:
Uncaught ReferenceError: module is not defined - this seems to be coming from the CDN's index.jsUncaught TypeError: window.iFrameResize is not a function - I'm guessing this is because of the above failed error.How can I correctly import via CDN and then use that npm package in script tags in my html?
CDN Link was pointing to the wrong JS file. Don't use the one from jsdelivr or direct from unpkg. Instead use: https://cdn.jsdelivr.net/npm/iframe-resizer@4.2.11/js/iframeResizer.min.js