逛奔的蜗牛

我不聪明,但我会很努力

   ::  :: 新随笔 ::  ::  :: 管理 ::

<html>


<head>

    <meta http-equiv="Content-type" content="text/html; charset=UTF-8">

    

    <style type="text/css"></style>

    

    <script src="js/jquery.js"></script>

    <script type="text/javascript">

    /*To determine the size of the IFrame's contents, you must access the height and width properties of the underlying IFrame document. Because you only have scripting access to pages that are hosted in the same domain, you can only access the properties to the pages that are hosted within the same domain (for example, Cross Frame Scripting). Therefore, the source document of the IFrame must be from the same domain as the page that contains the IFrame. From: http://support.microsoft.com/kb/278469*/

    

    $(function() {

        // 动态加载iframe. iframe的大小,必须在同一个域中才可以这样计算.

        $("#info").load(function(data) {

            $(this).height($(this).contents().find("#wrapper").height());

            $(this).width($(this).contents().find("#wrapper").width());

            // 对于宽度,不要使用find("body"),这个返回的值不准确

        }).attr("src", "2col.html");

        

        $("#ifm").load(function() {

            // 自动适应iframe的大小,不用像上一个方法那样麻烦的

            var body = this.contentDocument.body;

            this.style.pixelWidth  = body.scrollWidth;

            this.style.pixelHeight = body.scrollHeight;

        }).attr("src", "2col.html");

    });

    </script>

</head>

<body>

    Size of iframe<br>

    <!--<iframe src="2col.html" id="info" name="info" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>-->

    

    <iframe id="ifm" src="2col.html" frameBorder=0 scrolling=no>

</body>

</html>

posted on 2010-10-29 14:16 逛奔的蜗牛 阅读(1176) 评论(0)  编辑 收藏 引用 所属分类: Java其他编程

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理