document.getElementById()问题 有三个div id分别是1,2,3 parent.moni.document.getElementById(3).style.visibility = "visible";我想让第三个属性为显示 可为什么 所有的都显示出来了 谢谢 大家 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 you should use "1" "2" "3", because they are strings still have problem? send mail to me: [email protected] 同意楼上的id应该是String加上“”试试看 getElementById(3)?谁教你的写法?parent.frames["moni"].document.getElementById("ElementID").style.visibility = "visible"; 有三个div id分别是1,2,3 第一个:parent.moni.document.getElementById("1").style.visibility = "visible";第二个:parent.moni.document.getElementById("2").style.visibility = "visible";第三个:parent.moni.document.getElementById("3").style.visibility = "visible"; net_lover(【孟子E章】) ( ) 信誉:875 Blog 加为好友 大哥 我按你的写了 可还是和以前一样 把你的div和简单的代码贴出来呀就一个页面里3个div,很简单的问题 <div id="1" style="position:absolute; width:980px; height:48px; z-index:1; left: 4px; top: 3px; visibility: visible;"></div><div id="2" style="position:absolute; width:980px; height:48px; z-index:1; left: 4px; top: 3px; visibility: hidden;"></div><div id="3" style="position:absolute; width:980px; height:48px; z-index:1; left: 4px; top: 3px; visibility: hidden;"></div>function showlayer(idx){ for(a=1;a <= 3;a++){ parent.frames["moni"].document.getElementById(""+a+"").style.visibility = "hidden"; } parent.frames["moni"].document.getElementById(""+idx+"").style.visibility = "visible"; }先把所有的都隐藏 然后再让选中的显示出来 直接document.getElementById(idx).style.visibility = "visible";parent.frames["moni"]你不是在一个页面? 我认为div 的 id 取名字叫1,2,3是有问题的.如果把"1"换成"div1"document.getElementById("div"+1).style.visibility = "visible"; 应该就没有问题了. 改了 名字现在叫 div1 div2 div3 了 不过 我是在外面控制iframe里面的三个图层的 parent.frames["moni"].document.getElementById("div3").style.visibility = "visible";还是三个图层都显示 id="3" 这样的id是不合法的 ID String that specifies or receives any alphanumeric string that begins with a letter. The underscore (_) can also be used.-------------------------------只能用字母和_开头 我已经改成div1 div2 div3 了 问题还没解决 1.htm<iframe id="ff" src="2.html" width="500" height="600"></iframe><input type="button" name="Submit2" value="11111" onclick="shows(1)" /><input type="button" name="Submit3" value="22222" onclick="shows(2)" /><input type="button" name="Submit" value="33333" onclick="shows(3)" /><script>function shows(i){ var ff = frames["ff"]; var id = ff.document.getElementById("t"+i); for(var n=1;n<n+1;n++) { if((""+n)==i) { id.style.display="block"; }else{ ff.document.getElementById("t"+n).style.display="none"; } }}</script>2.html<!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>无标题文档</title><style type="text/css"><!--div { background-color: #666666; clear: both; height: 50px; width: 200px; margin-top: 10px; margin-bottom: 10px; border: 1px solid #333333;}--></style></head><body><div id="t1" name="111">11111</div><div id="t2" name="222">22222</div><div id="t3" name="333">33333</div></body></html> 注释IFRAME 元素也就是文档中的文档,或者好像浮动的框架(FRAME)。frames 集合提供了对 IFRAME 内容的访问。请使用 frames 集合读写 IFRAME 内包含的元素。例如,如果要访问 iframe 内 body 对象的 backgroundColor 样式,语法应为:sColor = document.frames("sFrameName").document.body.style.backgroundColor;通过 iframe 对象所在页面的对象模型,你可以访问 iframe 对象的属性,但不能访问其内容。例如,访问 iframe 对象的 border 样式的语法应为:sBorderValue = document.all.oFrame.style.border;注意 iframe 的属性必须使用前缀 document.all 访问,例如 document.all.iframeId.marginWidth。Internet Explorer 5.5 支持浮动框架的内容透明。如果想要为浮动框架定义透明内容,则必须满足下列条件。 与 IFRAME 元素一起使用的 ALLOWTRANSPARENCY 标签属性必须设置为 true。 在 IFRAME 内容源文档,background-color 或 BODY 元素的 BGCOLOR 标签属性必须设置为 transparent。 参看使用透明的浮动框架可以获得关于透明浮动框架更多的信息。此元素在 Microsoft® Internet Explorer 4.0 的 HTML 和脚本中可用。此元素是一个块元素。此元素需要关闭标签。 注意这一条通过 iframe 对象所在页面的对象模型,你可以访问 iframe 对象的属性,但不能访问其内容。例如,访问 iframe 对象的 border 样式的语法应为: 请教一个连接解发的问题 js 乱码问题 out of memory 问题 这个特效很常见...我想知道怎样实现它的? 问下subYear(obj)里的 var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes; .. 2个问题和在一起问 使用javascript+html实现类似资源管理器的树形菜单效果遇到难题,求教 帮我看1下以下的小段代码,为什么出错啊? 大家进来看看。100分毫无虚言。关于视窗的。 HELP! javascript里如何调用存储过程(带有返回的参数)? 求助阿 ,关于iframe
id应该是String
加上“”试试看
第一个:
parent.moni.document.getElementById("1").style.visibility = "visible";
第二个:
parent.moni.document.getElementById("2").style.visibility = "visible";第三个:
parent.moni.document.getElementById("3").style.visibility = "visible";
就一个页面里3个div,很简单的问题
for(a=1;a <= 3;a++){
parent.frames["moni"].document.getElementById(""+a+"").style.visibility = "hidden"; }
parent.frames["moni"].document.getElementById(""+idx+"").style.visibility = "visible";
}先把所有的都隐藏 然后再让选中的显示出来
document.getElementById("div"+1).style.visibility = "visible";
应该就没有问题了.
-------------------------------
只能用字母和_开头
<iframe id="ff" src="2.html" width="500" height="600"></iframe>
<input type="button" name="Submit2" value="11111" onclick="shows(1)" />
<input type="button" name="Submit3" value="22222" onclick="shows(2)" />
<input type="button" name="Submit" value="33333" onclick="shows(3)" />
<script>
function shows(i)
{
var ff = frames["ff"];
var id = ff.document.getElementById("t"+i);
for(var n=1;n<n+1;n++)
{
if((""+n)==i)
{
id.style.display="block";
}else{
ff.document.getElementById("t"+n).style.display="none";
}
}
}
</script>2.html
<!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>无标题文档</title>
<style type="text/css">
<!--
div {
background-color: #666666;
clear: both;
height: 50px;
width: 200px;
margin-top: 10px;
margin-bottom: 10px;
border: 1px solid #333333;
}
-->
</style>
</head><body>
<div id="t1" name="111">11111</div>
<div id="t2" name="222">22222</div>
<div id="t3" name="333">33333</div>
</body>
</html>
Internet Explorer 5.5 支持浮动框架的内容透明。如果想要为浮动框架定义透明内容,则必须满足下列条件。 与 IFRAME 元素一起使用的 ALLOWTRANSPARENCY 标签属性必须设置为 true。
在 IFRAME 内容源文档,background-color 或 BODY 元素的 BGCOLOR 标签属性必须设置为 transparent。
参看使用透明的浮动框架可以获得关于透明浮动框架更多的信息。此元素在 Microsoft® Internet Explorer 4.0 的 HTML 和脚本中可用。此元素是一个块元素。此元素需要关闭标签。
通过 iframe 对象所在页面的对象模型,你可以访问 iframe 对象的属性,但不能访问其内容。例如,访问 iframe 对象的 border 样式的语法应为: