<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>iframe 增高 减少问题 </title> 
<script type="text/javascript"> 
function $(id){return document.getElementById ? document.getElementById(id):null;} 
</script> 
</head> <body> 
<iframe id="c" marginwidth=0 marginheight=0 frameborder=1> </iframe> <br /> <br /> 
<input type="button" onclick="Height(100)" value="增高" /> 
<input type="button" onclick="Height(-100)" value="减少" /> 
<script type="text/javascript"> 
var content = $('c'); 
function Height(v){ 
var obj = content//.frameElement; 
var height = parseInt(obj.offsetHeight) + parseInt(v); 
if(height >= 200)obj.height = height; 

</script> 
</body> 
</html> 

解决方案 »

  1.   

    <!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>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>iframe 增高 减少问题 </title>
            <script type="text/javascript">
                function $(id){
                    return document.getElementById ? document.getElementById(id) : null;
                }
            </script>
        </head>
        <body>
            <iframe id="c" marginwidth=0 marginheight=0 frameborder=1>
            </iframe>
            <br/>
            <br/>
            <input type="button" onclick="Height(100)" value="增高" />
    <input type="button" onclick="Height(-100)" value="减少" />
            <script type="text/javascript">
                var content = $('c');
                function Height(v){
                    var obj = content;
                    var height = parseInt(obj.offsetHeight) + parseInt(v);
                    if (height >= 200) 
                        obj.height = height;
                }
            </script>
        </body>
    </html>