挺好的呀<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> New Document </title> </head><body> <iframe src="about:blank" id="Myframe"></iframe> </body> </html> <script language="JavaScript"> <!-- //document.frames["Myframe"].document.write("123"); var s = "Myframe"; document.frames[s].document.write("123"); //--> </script>
IFRAME.id = "IFRAME" + myid; //myid是一个变量
var st = IFRAME.style;
st.position = 'absolute';
st.left = 0 + 'px';
st.top = 0 + 'px';
st.width = 90 + 'px';
st.height = 10 + 'px';
st.zIndex = 100;
st.backgroundColor = "red";
st.display="none";
st.marginTop=0; //我想实现marginheight="0" marginwidth="0"不知道怎么写?
st.marginRight=0;
st.marginBottom=0;
st.marginLeft=0;
st.border=0; //我想实现frameborder="0" 不知道这么写对不对?document.body.insertAdjacentElement('beforeend',IFRAME);
var docu = window.frames["IFRAME" + myid].document;
docu.write(TinnerHTML); //TinnerHTML是一个字符串,结果就出我上面说的提示了,怎么办?
<html>
<head>
<title> New Document </title>
</head><body>
<iframe src="about:blank" id="Myframe"></iframe>
</body>
</html>
<script language="JavaScript">
<!--
//document.frames["Myframe"].document.write("123");
var s = "Myframe";
document.frames[s].document.write("123");
//-->
</script>
我开始以为是那个毛病,后来我也实验了,确实好用,但是也确实是那行出毛病了,提示就象我说的,请问为什么呢?
<body>
<script language="javascript">
for (var i=0;i<10;i++)
{
var IFRAME = document.createElement('IFRAME');
IFRAME.id = "IFRAME" + i; //myid是一个变量
var st = IFRAME.style;
st.position = 'absolute';
st.left = 0 + 'px';
st.top = 0 + 'px';
st.width = 90 + 'px';
st.height = 10 + 'px';
st.zIndex = 100;
st.backgroundColor = "red";
st.display="none";
st.marginTop=0; //我想实现marginheight="0" marginwidth="0"不知道怎么写?
st.marginRight=0;
st.marginBottom=0;
st.marginLeft=0;
st.border=0; //我想实现frameborder="0" 不知道这么写对不对? document.body.insertAdjacentElement('beforeend',IFRAME);
var docu = window.frames["IFRAME" + i].document;
docu.write(i);
};
</script>
</body>
<body>
<script language="javascript">
for (var i=0;i<10;i++)
{
var IFRAME = document.createElement('IFRAME');
IFRAME.id = "IFRAME" + i; //myid是一个变量
var st = IFRAME.style;
st.position = 'absolute';
st.left = 90 * i + 'px';
st.top = 0 + 'px';
st.width = 90 + 'px';
st.height = 100 + 'px';
st.zIndex = 100;
st.backgroundColor = "red";
//st.display="none";
st.marginTop=0; //我想实现marginheight="0" marginwidth="0"不知道怎么写?
st.marginRight=0;
st.marginBottom=0;
st.marginLeft=0;
st.border=0; //我想实现frameborder="0" 不知道这么写对不对? document.body.insertAdjacentElement('beforeend',IFRAME);
var docu = window.frames["IFRAME" + i].document;
docu.write(i);
};
</script>
</body>
IFRAME.id = "IFRAME" + i;改成 "IFRAME"
var docu = window.frames["IFRAME" + i].document;改成var docu = window.frames["IFRAME"].document;
在2000+ie6下就好了,也不知道为什么?
oElement = object . appendChild ( oNode )
根本创建不了iframe?
document.body.appendChild(obj);可以这么写吧?
根本创建不了iframe?ie5下不行document.body.appendChild(obj);可以这么写吧?
语法没错,但是对你解决这个问题没用,这个地方不是关键
叫用户们都升级到ie6是不是很过分呢?
IFRAME.outerHTML = IFRAME.outerHTML;
<script language="javascript">
for (var i=0;i<10;i++)
{
var IFRAME = document.createElement('IFRAME');
IFRAME.id = "IFRAME" + i; //myid是一个变量
var st = IFRAME.style;
st.position = 'absolute';
st.left = 90 * i + 'px';
st.top = 0 + 'px';
st.width = 90 + 'px';
st.height = 100 + 'px';
st.zIndex = 100;
st.backgroundColor = "red";
//st.display="none";
st.marginTop=0; //我想实现marginheight="0" marginwidth="0"不知道怎么写?
st.marginRight=0;
st.marginBottom=0;
st.marginLeft=0;
st.border=0; //我想实现frameborder="0" 不知道这么写对不对? document.body.insertAdjacentElement('beforeend',IFRAME);
var docu = window.frames["IFRAME" + i].document;
docu.write(i);
};
</script>
</body>
还有,怎么用甲苯实现以下的功能:
1、iframe的marginwidth=0
2、iframe的marginheight=0
3、frameborder=0
4、开始的饿时候iframe定义的可能很小,怎么让他的大小被里面的元素给撑起来,就象DIV被撑起来一样。
谢谢,谢谢了!!!
2, object.marginWidth
3, object.frameBorder
最最重要的是:开始的时候iframe定义的可能很小,怎么让他的大小被里面的元素给撑起来,就象DIV被撑起来一样。
在iframe载入的页面上写入
<body onload='parent.iframeId.width=document.body.scrollWidth;parent.iframeId.height=document.body.scrollHeight'>
docu.open();
docu.write(i);
docu.close();
<script language="javascript">
for (var m=0;m<10;m++)
{
var IFRAME = document.createElement('IFRAME');
IFRAME.id = "IFRAME" + m;
var st = IFRAME.style;
st.position = 'absolute';
st.left = 0 + 'px';
st.top = 0 + 'px';
st.width = 90 + 'px';
st.height = 100 + 'px';
st.zIndex = 100;
st.backgroundColor = "red"; document.body.insertAdjacentElement('beforeend',IFRAME);
IFRAME.outerHTML = IFRAME.outerHTML;
var docu = window.frames["IFRAME" + m].document;
docu.open();
docu.write("<body onload='alert(parent."+"IFRAME" + m +".id)'></body>");
docu.close();
}
</script>
</body>
为什么弹出来的是undefined呢?