如何在页面加载时将网页内容加载到 div 中? [英] How can I load webpage content into a div on page load?

查看:41
本文介绍了如何在页面加载时将网页内容加载到 div 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不使用iframes,是否可以加载

的内容

使用外部站点,例如somesitehere.com

页面何时加载?- 我知道如何从文件加载内容,但不确定如何加载整个网站?

非常感谢,

解决方案

这可以在没有 iframe 的情况下完成.jQuery 被使用,因为它在标题中提到.

<头><meta charset="utf-8"><title>将远程内容加载到对象元素中</title><身体><div id="siteloader"></div><script src="http://code.jquery.com/jquery-1.7.2.min.js"></script><脚本>$("#siteloader").html('<object data="http://tired.com/">');

Without using iframes, is it possible to load the contents of

<div id="siteloader"></div>

With an external site e.g. somesitehere.com

When the page loads? - I know how to load contents from a file, but wasn't sure how to load a whole site?

Many thanks,

解决方案

This is possible to do without an iframe specifically. jQuery is utilised since it's mentioned in the title.

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Load remote content into object element</title>
  </head>
  <body>
    <div id="siteloader"></div>​
    <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script>
      $("#siteloader").html('<object data="http://tired.com/">');
    </script>
  </body>
</html>

这篇关于如何在页面加载时将网页内容加载到 div 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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