iframe的问题 是不是这个iframe还没load出来?--------------------------------------------如果你怀疑这方面原因可以等页面加载完 再手动设置样式试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 document.frames('framename').Document.getElementById('hrefname').style.height='1000px' 如果是加载问题用defer="true"属性试试看<script defer="true"> .... document.frames['framename'].document.xxxxx</script> 测试通过:<body onload="chgHeight()"> <iframe id="framename" src="1.htm"></iframe><script>function chgHeight(){ framename.document.getElementById("objid").style.height="1000px";}</script></body> <iframe id="framename" src=""></iframe><script type="text/javascript"> window.framename.document.all["hrefname"].style.height="1000px";</script> 我把完整代码写出来吧:index.html:<html><head><script defer="true"> document.frames('framename').Document.getElementById('divname').style.height='1000px'</script></head><body> document.write('<iframe id=framename src=1.html></iframe>');</body></html>1.html:<html><head><body><div id="linkname">content></a></body></html>按照楼上同学的方法加了defer属性,但是还是无法修改该div的高度 我把完整代码写出来吧: index.html: <html> <head> <script defer="true"> document.frames('framename').Document.getElementById('divname').style.height='1000px' </script> </head> <body> document.write(' <iframe id=framename src=1.html> </iframe>'); </body> </html> 1.html: <html> <head> <body> <div id="divname">content> </a> </body> </html> 按照楼上同学的方法加了defer属性,但是还是无法修改该div的高度 以下测试通过:index.html<html><body onload="chgHeight()"> <script language="javascript">document.write("<iframe id=framename src=\"1.html\"></iframe>"); function chgHeight(){ framename.document.getElementById("divname").style.height="1000px";}</script></body> </html>1.html<html> <head> <body> <div id="divname">content </div> </body> </html> 如果你不确定是否加载完毕 简单可以这样写 if(document.frames('framename').contentDocument.getElementById('hrefname')) document.frames('framename').contentDocument.getElementById('hrefname').style.height='1000px'; <html> <head> <script defer="true">window.onload=function(){alert(); document.frames['framename'].document.getElementById('divname').style.height='1000px'}</script></head> <body><script> document.write("<iframe name='framename' id='framename' src='1.html'><\/iframe>");</script></body> </html><html> <head> <body> <div id="divname">content</div> </body> </html> 如果是高度自适应问题请参考:http://topic.csdn.net/t/20061026/21/5112244.html 基本概念:任何函数体外的代码会被立刻执行,因为你执行第一条js的时候,还没这个iframe,会报错。当然,用defer属性也可延迟执行。 求教~为什么程序只能在Editplus中运行,IE和谷歌都不行? (100分)学习了javascript基础后,该继续哪一步?请大神们说说 这几个破坐标属性快把人整疯了。。。 求助!! 像下面网页中左边的菜单是如何实现的?网址是: 新人提问 菜鸟学做列表,但是提示错误? 帮忙看一下这个正则表达式 如何显示完整的警告语句? 为何模式窗口不会触发第二次page_load事件 function window.onload(){...}和 window.onload = somefunc; function somefunc(){...}有什么区别吗? 页面返回到不同的上一页怎么弄
<script defer="true">
....
document.frames['framename'].document.xxxxx
</script>
<iframe id="framename" src="1.htm"></iframe>
<script>
function chgHeight()
{
framename.document.getElementById("objid").style.height="1000px";
}
</script>
</body>
window.framename.document.all["hrefname"].style.height="1000px";
</script>
index.html:
<html>
<head>
<script defer="true">
document.frames('framename').Document.getElementById('divname').style.height='1000px'
</script>
</head>
<body>
document.write('<iframe id=framename src=1.html></iframe>');
</body>
</html>1.html:
<html>
<head>
<body>
<div id="linkname">content></a>
</body>
</html>按照楼上同学的方法加了defer属性,但是还是无法修改该div的高度
index.html:
<html>
<head>
<script defer="true">
document.frames('framename').Document.getElementById('divname').style.height='1000px'
</script>
</head>
<body>
document.write(' <iframe id=framename src=1.html> </iframe>');
</body>
</html> 1.html:
<html>
<head>
<body>
<div id="divname">content> </a>
</body>
</html> 按照楼上同学的方法加了defer属性,但是还是无法修改该div的高度
index.html<html>
<body onload="chgHeight()">
<script language="javascript">
document.write("<iframe id=framename src=\"1.html\"></iframe>");
function chgHeight()
{
framename.document.getElementById("divname").style.height="1000px";
}
</script>
</body>
</html>
1.html<html>
<head>
<body>
<div id="divname">content </div>
</body>
</html>
if(document.frames('framename').contentDocument.getElementById('hrefname'))
document.frames('framename').contentDocument.getElementById('hrefname').style.height='1000px';
<html>
<head>
<script defer="true">
window.onload=function(){alert();
document.frames['framename'].document.getElementById('divname').style.height='1000px'
}
</script>
</head>
<body>
<script>
document.write("<iframe name='framename' id='framename' src='1.html'><\/iframe>");
</script>
</body>
</html><html>
<head>
<body>
<div id="divname">content</div>
</body>
</html>
http://topic.csdn.net/t/20061026/21/5112244.html