IFRAME的问题 [英] Problem with IFRAME

查看:79
本文介绍了IFRAME的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,即如何根据IFRAME中的内容大小将IFRAME拉伸到100%的高度.我在这里找到了一个窍门.一切都在测试页中正常运行(仅此iframe的几乎所有空白页).但是,当我将此代码插入MasterPage页面时,出现错误:Microsoft JScript runtime error: ''document.frames[...].document'' is null or not an object.接下来做什么?如何解决此问题?

我在前面找到的建议解决方案:

I had the problem with the issue how to stretch IFRAME to 100% height depending on the content size in IFRAME. I found out 1 trick here. And all has been working properly in the test page (almost empty page whith this iframe only). But when I inserted this code into page with MasterPage I got an error: Microsoft JScript runtime error: ''document.frames[...].document'' is null or not an object. What to do next? How to fix this problem?

The suggested solution I found out earlier here:

<script type="text/javascript">
        function getElement(aID) {
            return (document.getElementById) ?
            document.getElementById(aID) :

document.all[aID];
        }

        function getIFrameDocument(aID) {
            var rv = null;
            var frame = getElement(aID);
            // if contentDocument exists, W3C 

            //compliant(e.g.Mozilla)
            if (frame.contentDocument)
                rv = frame.contentDocument;
            else // bad Internet Explorer  ;)
                rv = document.frames[aID].document;
            return rv;
        }

        function adjustMyFrameHeight() {
            var frame = getElement("frmLection");
            var frameDoc = getIFrameDocument("frmLection");
            frame.height = frameDoc.body.offsetHeight;
        }
    </script>



和HTML内容:



and HTML content:

<iframe id="frmLection" frameborder="0" width="100%" scrolling="no">
                        src="Lection1.html" runat="server">
                    </iframe>



有人可以给我一些建议吗?预先感谢.



Could somebody give me some advice? Thanks in advance.

推荐答案

Pavel,

您需要发送IFrame广告代码的客户端ID,通常,当控件基于页面设计呈现给浏览器时,客户端ID会发生变化.在浏览器页面的查看源代码"中检查生成的iframe ID.
Pavel,

You need to send the client side id of the IFrame tag, generally the client id changes for the controls when rendered to browser based on the page design. Check for the resulting iframe id in the ''View Source'' of the page in the browser.


这篇关于IFRAME的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆