在DIV中显示页面 [英] Show page in DIV

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

问题描述

我想从另一个页面(.html)获取div内容并将其显示为我的页面样式。



div高度应根据内容因为它与页面底部对齐,需要保持这样的状态。



这是可能的吗?

解决方案

如果您希望使用本地样式创建远程文件中的内容,则必须将样式加载到包含该远程文件的iframe中(删除任何竞争样式表),或者将远程文件中的内容加载到本地文件中。后者可能更容易。

许多工具都可以在线存在以帮助您完成此操作。例如, jQuery (世界上最流行的JavaScript库)可以异步加载远程文件,然后将其中的一部分添加到父文件:

  $(#page)。load(remote.html#内容); 

这将获取 #content 在页面 remote.html 上,并将它们放在当前页面的 #page 中。


I want to get div content from another page (.html) and display it with the styling of my page.

The div height should size depending on the content since it's aligned to the bottom of the page and needs to stay like this.

Is this possible in any way?

解决方案

If you wish to have the content from the remote file styled with your local styles, you would either have to load your styles into an iframe containing that remote file (removing any competing stylesheets), or load the content from the remote file into your local file. The later is probably easier.

Many tools exist online to assist you in doing this. For instance, jQuery (world's most popular JavaScript library) can asynchronously load a remote file and then add portions of it to the parent document:

$("#page").load("remote.html #content");

This would grab the contents of #content on page remote.html, and place them within #page on the current page.

这篇关于在DIV中显示页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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