外围页面中引用了一个iframe 我想让iframe的高度固定 我用的方法是 用外围页面的clientHeight减去顶部导航的高度 。
现在的问题是,刷新整个外围页面时,这么做可行,但当我点击左侧导航,刷新iframe页面时,点一次,clientHeight会自动增加26px。不知道是什么问题,求高手指点。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="index" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7">
<title>管理中心</title>
<link rel="shortcut icon" href="__PUBLIC__/Images/favicon.ico" />
<link href="__PUBLIC__/Css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">function set_height(){
document.getElementById('mainframe').height = window.top.document.clientHeight - 60;
}</script>
<meta name="save" content="history">
</head>
<body>
<div id="wrapper">
<div id="header">
<div class="logo"></div>
<div class="menu">
         <a href="<?php echo U('Site/index'); ?>" class="item_menu<?php if($ == 'Site')echo ' current'; ?>">网站管理</a>
         <a href="<?php echo U('Case/index'); ?>" class="item_menu<?php if($ == 'Case')echo ' current'; ?>">案例管理</a>
         <a href="<?php echo U('User/index'); ?>" class="item_menu<?php if($ == 'User')echo ' current'; ?>">用户管理</a>
        </div>
<div class="log-info">
         <span>欢迎回来:{$user_name}</span>
            <em>|</em>
            <a href="__APP__/Login/loginOut">退出系统</a>
            <em>|</em>
            <a href="javascript:void(0)" onclick="javascript:parent.mainframe.location.reload();">刷新主窗口</a>
            <a class="back-home" href="__APP__/" target="_blank">返回首页</a>
        </div>
</div>
<div id="container">
<div class="sidebar">
       <div class="sub-menu">
   <h3 class="sidebar-title-top">网站管理</h3>
   <div class="sub-menu-info">
   <a href="__URL__/add_info" target="mainframe">添加信息</a>
   <a href="__URL__/site" target="mainframe">查看信息</a>
   </div>
   </div>
</div>
<div class="main">
            <iframe id="mainframe" width="100%" name="mainframe" height="480px" frameborder="0" src="__URL__/site" onload="set_height()"  scrolling="yes"></iframe>
</div>
</div>
</div>
</body>
</html>