Frameset frame 布局 IE7/8/9 内存泄露

gavinluo gavinluo 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这种布局存在内存泄露,站点使用一会内存就涨上去了,然后整个响应很慢,客户端是Xp IE7/IE8 ,我的页面布局是这样的:

FrameMain.aspx页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<TITLE></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<frameset rows="46,*" framespacing="0" frameborder="no" border="0" noResize scrolling="no">
<frame name="banner" src="WebForm_logo.aspx" noResize scrolling="no"/>
<frameset id="frame" cols="7,156,7,*,7" framespacing="0" frameborder="no" border="0" name="frame" noResize scrolling="no">
<frame name="left" id="left" noresize src="leftframe.aspx" scrolling="no">
<frame name="Menu" id="Menu" noresize src="Menu.aspx">
<frame name="border" id="border" scrolling="no" noresize src="middle.aspx">
<frame name="main" id="main" src="<%=MainUrl %>">
<frame name="right" id="right" scrolling="no" noresize src="rightframe.aspx">
</frameset>
</frameset>
</head>
<body>

</body>
</html>


我在Menu.aspx 中用 <a target='main' href='导航内容页面'> 来控制 main frame显示。

但是我发现长时间使用,会引起内存泄露,我参考网上尝试了一些方法 比如我在Menu.aspx页面中调用下面这个方法来清空Frame。

function clearFrame(){
var frame = window.parent.document.getElementById("main");
frame.src = 'about:blank';
frame.contentWindow.document.write('');//清空frame的内容
frame.contentWindow.document.clear();
frame.contentWindow.close();//避免frame内存泄漏
frame.parentNode.removeChild(frame);
CollectGarbage();
var newIfm = window.parent.document.createElement('frame');
newIfm.id = 'main';
newIfm.name = 'main';
var c = window.parent.document.getElementById("right");
c.insertBefore(newIfm);
}

我清空这个Frame,再从新创建一个。但有两个问题
1.内存没有减下去
2.再次清理的时候window.parent.document.getElementById("main")已经获取不到这个新添加进去的frame。

请高手来协助~~
...全文
评论 10
收藏 已收藏
分享
返回顶部
gavinluo
.NET社区 62,271 成员 668,968 内容