简体   繁体   English

jQuery:在div中加载html页面

[英]jquery: loading html page inside a div

I'm loading an html page inside a div using: 我正在使用以下方法在div中加载html页面:

$("#page1").html('<object data="http://stackoverflow.com/">');

the problem is that the loaded page is very small in display: the div is 500*500px but the page inside of it is only 100*100px , no matter what i do. 问题是加载的页面在显示中非常小:div为500*500px但其中的页面仅为100*100px ,无论我做什么。

please help me solve this thank you 请帮我解决这个谢谢

object标签中使用widthheight属性。

<object data="http://stackoverflow.com/" width="500" height="500">

只需在创建对象时添加高度宽度:

$("#page1").html('<object width="100%" height="100%" data="http://stackoverflow.com/">');

You can use Jquery load function. 您可以使用Jquery加载功能。 It will help you. 它会帮助你。
Here is the example:- 这是示例:

<!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>Include</title>
        </head>
        <body>
            <div id="include"></div>
            <a id="link" href="#">Click Test Link</a>

            <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
            <script type="text/javascript"> 
                $("#link").click(function(){
                    $("#include").load("include/test.html"); 
                });
            </script> 
        </body>
    </html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM