Website construction

Knitting! Testing iframe cross domain adaptation failed!

Jager · March 20 · 2014 · 2756 times read

I thought it could be launched successfully Mutual promotion alliance iframe Dual mode, the test of my own website is successful, and finally I found that other people's calls can not be adaptive, only my own website can be adaptive, depressed!!!

The following quotes are some articles that I worked hard to sort out in the afternoon. Finally, I was discouraged when I found that they failed. The articles just released had to be changed to draft status, and I went home and continued to check the information for half a day. I found that if I wanted to iframe Cross domain can also adapt to height. We must create an intermediate page for callers on our website( Detailed Tutorial )!

That is to say, as long as a blogger calls my iframe, I have to make a middle page corresponding to his domain name, and I will do some knitting!

Forget it. Don't bother with this thing, just keep it as it is!

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

24 responses
  1. Dragon Third Young Master 2014-3-20 · 21:18

    Can't the caller modify the width and height in the iframe code?

  2. WordPress Theme 2014-3-20 · 21:58

    -- Toss is always a pain in the egg. Continue to think of other ways.

    •  avatar
      Jager 2014-3-20 · 22:17

      Well, let's leave it like this for the time being~~Look for information again when you are free.

      • March 2014-3-21 · 0:03

        Let's talk about the plug-in of Baidu, the external chain you mentioned before. I can't find the reply

  3. Liu Jun Blog 2014-3-20 · 22:55

    It doesn't mean much.

    •  avatar
      Jager 2014-3-20 · 23:13

      Both [Floating clouds]

  4. March 2014-3-20 · 23:19

    I used to be very normal. Why can't I adapt

    •  avatar
      Jager 2014-3-20 · 23:38

      You forgot? Comments that already exist when you call cannot be displayed... Because the comments are post loaded, the adaptation fails, so the comments are not displayed... This adaptation can only support the same domain name. It is troublesome to create an intermediate page across domains... One on one..

      • March 2014-3-20 · 23:47

        It is too troublesome to implement. In this case, there is no comment and nothing else will affect

        •  avatar
          Jager 2014-3-20 · 23:49

          Well, this is also OK. If there is a comment, it will cause a certain load on my space.

          • March 2014-3-20 · 23:55

            Or you can get one in your own place and use it

  5. xiaoz 2014-3-21 · 8:27

    It's a trend to study self adaption when I look back. I can't stand standing under my mobile phone, but I don't know what's going on.

    •  avatar
      Jager 2014-3-21 · 8:48

      Indeed, it is predicted that the Internet will become the mobile world in the future.

  6. Kindle house 2014-3-21 · 10:43

    Adaptive, this is the trend
    We have to study and explore slowly

    •  avatar
      Jager 2014-3-21 · 13:54

      The same domain name is still very easy to handle, but it is difficult to handle cross domain names.

  7. Alick.Li 2014-3-21 · 10:49

    Amount/ Self adaptation needs to adjust the width of different screens. This is why my navigation station directly removes the self adaptation from the whole station

    •  avatar
      Jager 2014-3-21 · 13:53

      It's troublesome. The same top-level domain name is OK, but cross domain adaptation is too troublesome, and the corresponding intermediate page needs to be established, so the iframe can't be universal. I have to make an intermediate page for each user separately, which is a waste of fuel..

  8. Mengxuan Beauty 2014-3-28 · 14:05

    I feel that it works normally all the time and loads very quickly!

    •  avatar
      Jager 2014-3-28 · 16:54

      Life Baixiaotang said that this thing slowed down the website..

      • Mengxuan Beauty 2014-3-28 · 17:06

         [Sweat] Can it slow down the whole website just by putting it on the friend chain or message office? Personally, it doesn't matter. Not every article is loaded.

        •  avatar
          Jager 2014-3-28 · 17:18

          It doesn't matter. Now let it be.