首先,我要说的是,我对采用完全不同的方法持开放态度。
我有一个这样的 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 load 的其他页面的后端处理。
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>