使用 iframe 显示网页的一部分
Display a part of web page using iframe
我在网页上有一个动态表,我在另一个应用程序上调用该页面。 我正在尝试单独显示该表而不是整个页面。所以我根据堆栈交换的其他一些答案编写了一段代码。但它仍然显示整个页面。如果表格只有 2 行,则它显示包含 2 行的表格和整个空白页面。无法弄清楚出了什么问题。还有其他办法吗?
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.getElementById("dvMain").offsetHeight + 'px';
// alert(obj.style.height);
}
</script>
<iframe src="www.google.com" width="100%" marginwidth="0" marginheight="0" frameBorder="0" id="iframe" onload='javascript:resizeIframe(this);'>
</iframe>
function tableFromUrl(url, target, before){
url is the file path,
target is an element to append the table to, if there are two arguments.
Or, if a third argument is true, insert the table before the target element.
try{
var O= new XMLHttpRequest(), txt,
div= document.createElement('div');
O.open('GET', url, true);
O.onreadystatechange= function(){
if(O.readyState== 4 && O.status== 200){
txt= O.responseText;
div.innerHTML=txt.substring(t.search(/<table/), t.search(/<'/table>/))+'</table>';
if(before=== true) target.parentNode.insertBefore(div, target);
else target.appendChild(div);
}
}
O.send(null);
}
catch(er){
//error handler
}
}
相关文章:
- 仅重新加载网页的一部分
- 如何使网页的一部分不与页面的其余部分滚动
- 新窗口中网页的一部分
- 如何截屏网页的一部分,然后用Javascript将其传递给服务器
- 使用 PHP 更新网页的一部分
- 使用 iframe 显示网页的一部分
- 如何在不正确重新加载整个页面的情况下更改网页的一部分
- 使用 jQuery $.post() 方法获取另一个网页的一部分
- 使用 CSS 打印网页的一部分
- 捕获移动设备网页的一部分
- 仅使用 html 将网页的一部分插入到另一个网页中
- 使用 XMLHttpRequest 获取网页,但只获取 html 的一部分
- 只打印网页的一部分
- 确定网页的一部分在浏览器中保持可见的时间
- 将动态网页(Kibana)的一部分嵌入到我自己的网站中
- 在iframe中加载网页,但替换iframe页面中url的一部分
- 如何填写值=从网页的另一部分的形式部分
- 使画布的一部分链接到另一个网页
- 我如何在我的网页内嵌入一个特定的名称属性的网页的一部分
- 如何重新加载,网页的一部分,在给定的时间后