0

I have two sites that I am sort of melding together. I'm using and iframe to display content from one page in the other as if it were all one site. The caveat here is that I need the page to display as normal when viewed in an iframe and to display a warning otherwise. I cannot import the iframe page into the host page due to IIS incompatibility so that option is out. The plan works fine when I simply display the page under all circumstances, it is when I try to implement the conditional display that I run into problems. On the iframe page I have the following:

<script type="text/javascript">
    window.onload = function InFrame() {
        MainContent_siteIsNotFramed
        if (top != self) {
            //document.getElementById("siteIsFramed").style.display = "inline"
            siteIsFramed.visible = "true"
        }
        else {
            //document.getElementById("MainContent_siteIsNotFramed").style.display = "inline"
            siteIsNotFramed.visible = "true"
        }
        init();
    };
</script>

This is my attempt to get the iframe page to handle its own conditional display. The only relevant code I have in the host page is the iframe itself which, for completelness, looks like this:

</head>
<body style="margin:0; height: 100%;">

<iframe  runat="server" id="signInFrame" style="border: 0; width: 100%; height: 100%; ">
    Your browser does not support iframes. Consider upgrading.
</iframe>
</body>
</html>

When the content to display/not display, the content in the iframe will display with about half height. Without, it displays at full height (desired behavior). I've tried to be as thourough as possible, if anyone needs more details, let me know.

4

1 に答える 1

1

iframeを「配置」してみてください。

<iframe  runat="server" id="signInFrame" style="border: 0; position:absolute; width: 100%; height: 100%; ">
   Your browser does not support iframes. Consider upgrading.
</iframe>

問題は、デフォルトの位置(位置:静的)のiframeは「相対的な」高さ(つまり%)を持つことができないため、height:100%を無視し、iframeの「デフォルト」の高さ(150px)を適用することです。 FFで)。

于 2012-11-28T03:47:15.563 に答える