Closed MostHated closed 5 years ago
Looks like I finally got it worked out. I am kicking myself in the face though, because I spent several hours trying to diagnose why the contents were no longer communicating with the parent.
In NodeBB, there are different areas you can drag your widgets. Somehow my iframe-resizer code widget got moved to the "Drafts" section, which meant it was no longer showing up on the live page...
I am just glad I got it all worked out. If anyone needs it, here is what I ended up using.
<!-- Code in a WordPress page block -->
<style>
iframe {
width: 1px;
min-width: 100%;
}
</style><iframe id="forum_frame" src="https://forum.mysite.dev" width="100%" scrolling="no"></iframe>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.0.4/iframeResizer.min.js"></script>
<script>
iFrameResize({
log: false,
checkOrigin: false,
heightCalculationMethod: 'taggedElement'
}, '#forum_frame')
</script>
<!-- In NodeBB footer widget -->
<div data-iframe-height> </div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.0.4/iframeResizer.contentWindow.min.js" defer></script>
It's important to note the \ (code for a blank space). Without it, the div is not able to be detected by iframe-resizer.
Thanks, -MH
Good evening, Thank you for sharing this fantastic application, it seems like it is going to be extremely useful. I had a question on the best way to go about utilizing this, if you do not mind. I am currently using WordPress as the main window/parent and I have a page which has the following code in it:
In my WordPress (WP), I follows some information that was linked that I had found somewhere (either here, or StackOverflow I think?) which has me make a child theme in WP and then add a new file called functions.php, which lets me add additional functionality without modifying the source files which has the code below. It also had me create a new .js file (iframe.js) in which I have the the code that is below that:
Lastly, in NodeBB I created a widget and placed it as the footer of each page, which contains the following code:
Now, everything works, for the most part, that is. My WP site has a forum tab in the menu, I hit that, it loads the static forum page (which ends up being https://mysite.dev/forum) and then the iframe loads the forum in it (which is https://forum.mysite.dev) and it resizes initially.
The two issues I am having are:
If I click on, say, a user to view their profile, it resizes and looks great. If I go to anything that is a smaller height though, it never shrinks.
I keep getting hundreds of the same message repeating over and over, which is the following, even with logging set to false:
As well as these error messages:
This is just from moving my mouse around the page. So I suppose my question might relate to both. I believe NodeBB loads it's pages without reloading the actual page. I was at first wondering if it was able to detect properly that anything was happening but it must, as it will get bigger each time, just not smaller. Is there a different way I need to go about setting this up for this type of application (Node.js) so it will properly work? I have been trying to look at other examples on github by just searching for "iframeResizer.contentWindow.js", but I have not been able to really find anything that seems to be using a similar setup.
Would you recommend addition of any other specific attributes or perhaps trying to call/execute a method of some sort between the parent/child? It seems likely that because NodeBB is a much more advanced application that just a standard html page that it probably requires use of some of the more advanced features of iframe-resizer, I honestly am just not sure which ones.
If perhaps you would be willing to throw me a suggestion, or point me in the right direction, I would greatly appreciate it! I will try to post this in the NodeBB forum as well, so that if there happens to be anything on the NodeBB side I have to do to try and accommodate this setup, someone there might be able to recommend it as well. I am hopeful that between your expertise in this, and theirs in NodeBB, a solid solution can be produced!
Thank you and I definitely appreciate the time and effort you have put into this library, -MH