Original text:《 Mutual promotion alliance Iframe Launches Dual Mode
Many alliance members have suggested adding public comment function to the general iframe module. In fact, Masker tried it a few days ago, and it is easy to implement. You just need to add the code that calls comments, but has been wondering whether this function will cause trouble to the bloggers who call the module? For example, does a blogger prefer a clean and simple interface?
Well, in fact, this is not a problem, so I will make two templates: A communication mode with comments and text modules ; A refreshing mode containing only the member list and bottom scrolling announcements , no more nonsense, just code:
1、 Communication mode
Iframe code with comments and text modules <iframe id="rightFrame" name="rightFrame" scrolling="no" src="/alliance" frameborder="0" onload="this.style.height='475px'" style="padding: 0px; width: 100%;"></iframe> <script type="text/javascript"> var browserVersion= window.navigator.userAgent.toUpperCase(); function reinitIframe(){ try{ var iframe=document.getElementById('rightFrame'); var bHeight=0; if(browserVersion.indexOf("CHROME")==-1 && browserVersion.indexOf("SAFARI")==-1) bHeight=iframe.contentWindow.document.body.scrollHeight; var dHeight=0; if(browserVersion.indexOf("FIREFOX")!=- 1) dHeight=iframe.contentWindow.document.documentElement.offsetHeight + 2; else if(browserVersion.indexOf("MSIE")==-1 && browserVersion.indexOf("OPERA")==-1) dHeight=iframe.contentWindow.document.documentElement.scrollHeight; else bHeight=bHeight+3; //alert("bHeight="+bHeight+"--dHeight="+dHeight+"--"+browserVersion); var height = Math.max(bHeight, dHeight); iframe.style.height=height+"px"; }catch (ex){} } window.setInterval("reinitIframe()",200); </script>
2、 Refreshing mode
There are no comments and text modules, but there are rolling announcements at the bottom (mainly used to notify the latest activities!) <iframe id="rightFrame" name="rightFrame" scrolling="no" src="/bokehutui" frameborder="0" onload="this.style.height='475px'" style="padding: 0px; width: 100%;"></iframe> <script type="text/javascript"> var browserVersion= window.navigator.userAgent.toUpperCase(); function reinitIframe(){ try{ var iframe=document.getElementById('rightFrame'); var bHeight=0; if(browserVersion.indexOf("CHROME")==-1 && browserVersion.indexOf("SAFARI")==-1) bHeight=iframe.contentWindow.document.body.scrollHeight; var dHeight=0; if(browserVersion.indexOf("FIREFOX")!=- 1) dHeight=iframe.contentWindow.document.documentElement.offsetHeight + 2; else if(browserVersion.indexOf("MSIE")==-1 && browserVersion.indexOf("OPERA")==-1) dHeight=iframe.contentWindow.document.documentElement.scrollHeight; else bHeight=bHeight+3; //alert("bHeight="+bHeight+"--dHeight="+dHeight+"--"+browserVersion); var height = Math.max(bHeight, dHeight); iframe.style.height=height+"px"; }catch (ex){} } window.setInterval("reinitIframe()",200); </script>
3、 Usage
Detailed usage of the above code=> https://zhang.ge/2073.html