【发布时间】:2011-05-04 11:11:15
【问题描述】:
首先让我说我对完全不同的方法持开放态度。
我有这样的 iframe:
<div id="testloadlogin">
<iframe src="../security/login.aspx" width="400" height="500"
scrolling="auto" frameborder="1">
[Your user agent does not support frames or is currently configured
not to display frames. However, you may visit
<a href="../security/login.aspx">the related document.</a>]
</iframe>
</div>
使用 iframe 加载的页面有一个名为 loginInnerBox 的 div。我只想显示 loginInnerBox 和其中的所有内容。
关于如何做到这一点的任何想法?我正在考虑使用 Jquery 或某种类型的 javascript 来删除 iframe 加载的页面上的所有其他内容,但不知道如何访问它...
为了清楚起见,我希望 iframe 之外的页面上的所有内容保持不变。我想要相当于说 $.('testloadlogin').load('../security/login.aspx' #loginInnerBox) ,它只会获取 loginInnerBox 的 html 并将其放在 testloadlogin div 中。但是,我需要 iframe 支持的其他页面的后端处理,但 Jquery 负载不支持。
iframe加载的页面的标记是
<body>
<div>
</div>.......
<div class="AspNet-Login" id="ctl00_CLPMainContent_Login1">
<div id="loginInnerBox">
<div id="loginCreds">
<table>
</table>
</div>
</div>
</div>
<div>
</div>....
</body>
您还需要更多信息吗?
我试过了,没有效果:
<div class="ui-corner-all" id="RefRes">
<div id="testloadlogin">
<iframe onload="javascript:loadlogin()" id="loginiframe" src="../security/login.aspx"
scrolling="auto" frameborder="1">
[Your user agent does not support frames or is currently configured
not to display frames. However, you may visit
<a href="../security/login.aspx">the related document.</a>]
</iframe>
</div>
</div>
<script type="text/javascript">
function loadlogin() {
$('<body>*', this.contentWindow.document).not('#ctl00_CLPMainContent_Login1').hide();
}
</script>
【问题讨论】:
-
我不明白。 “仅显示框”是什么意思?您希望其他内容发生什么? iframe 之外的内容呢?
-
对不起。 iframe 内的其余内容我想消失。 iframe 之外的内容我想保持不变。
-
这取决于iframe中加载的页面的标记,如何做,所以请显示标记。
-
发布了一个总体布局,如果您愿意,我可以发布 while 页面...
标签: javascript jquery iframe html