大家好,帮忙看下这个代码,在IE里面能正常调取src的内容到网页显示,但在火狐里提示"document.all is not a function",并且不能正常显示出来,各位大神,教我。谢谢!document.writeln("<BODY align=center>");
document.writeln("<table width=\"1002\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
document.writeln("<tr>");
document.writeln("<td><iframe name=\"Showme\" src=\"/game.asp\" width=1002 height=2500 scrolling=no onload=document.all('Showme').height=Showme.document.body.scrollHeight+0 border=\"0\" frameborder=\"0\" ></iframe><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<\/BODY>");
document.writeln("<table width=\"1002\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
document.writeln("<tr>");
document.writeln("<td><iframe name=\"Showme\" src=\"/game.asp\" width=1002 height=2500 scrolling=no onload=document.all('Showme').height=Showme.document.body.scrollHeight+0 border=\"0\" frameborder=\"0\" ></iframe><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<\/BODY>");
<html>
<head>
<meta charset="gb2312" />
<title></title>
</head>
<body>
<script>
document.writeln("<BODY align=center>");
document.writeln("<table width=\"1002\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
document.writeln("<tr>");
document.writeln("<td><iframe name=\"Showme\" src=\"http://www.baidu.com/\" width=1002 height=2500 scrolling=no onload=document.all('Showme').height=Showme.document.body.scrollHeight+0 border=\"0\" frameborder=\"0\" ></iframe><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<\/BODY>");
</script>
</body>
</html>没问题啊。
给iframe弄个id值 ,然后
document.getElementById('Showme')
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
</head>
<body>
<script>
document.writeln("<BODY align=center>");
document.writeln("<table width=\"1002\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
document.writeln("<tr>");
document.writeln("<td><iframe name=\"Showme\" id=\"Showme\" src=\"http://www.baidu.com/\" width=1002 height=2500 scrolling=no onload=document.getElementById('Showme').height=Showme.document.body.scrollHeight+0 border=\"0\" frameborder=\"0\" ></iframe><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<\/BODY>");
</script>
</body>
</html>改下 getElementById 就可以了。
楼主要 iframe自适应高度的话,搜下吧,很多相关信息的。