如下:
<td width="864" valign="top"><IFRAME marginWidth=0 marginHeight=0 frameBorder=no scrolling=auto name=mq src="bg.htm" width=100% height=100%><div id=nnb></div></IFRAME></td>如何在父页给<IFRAME 内的 <div id=nnb></div>传值呢?
<td width="864" valign="top"><IFRAME marginWidth=0 marginHeight=0 frameBorder=no scrolling=auto name=mq src="bg.htm" width=100% height=100%><div id=nnb></div></IFRAME></td>如何在父页给<IFRAME 内的 <div id=nnb></div>传值呢?
window.frames["iframe_ID"].document.getElementById("iframe_document_object").object_attribute = attribute_value 子窗口调用父窗口
parent.document.getElementById("parent_document_object").object_attribute = attribute_value
在父窗口中:这样可以取到iframe的document,window.frames["frame1"].document
然后可以:window.frames["frame1"].document.getElementById("o")在子窗口中可以:
window.parent.document.getElementById等,
或者
document.frames[0].document.getElementById("nnb").innerHTML = "xx";
如果iframe有id的话,也可以:
document.getElementById("iframe_id").contentWindow.document.getElementById("nnb").innerHTML = "xx";
<script>
function d()
{
document.getElementById("nnb").innerHTML="数据载入中..."
}
<script><a href=bg2.asp tqarget=qm onclick=d()>测试一下</a><table><tr><td width="864" valign="top"> <IFRAME marginWidth=0 marginHeight=0 frameBorder=no scrolling=auto name=mq src="bg.htm" width=100% height=100%> <div id=nnb> </div> </IFRAME> </td>
</tr><table>
总之是要在IFRAME中的页面未打开前在IFRAME那页显示“数据载入中”
<style type="text/css">
.opaqueLayer{display:none;position:absolute;top:0px;left:0px;opacity:0.6;filter:alpha(opacity=60);background-color: #000000;z-Index:1000;}
</style>
<script type="text/javascript">
function getBrowserHeight() {
var intH = 0;
var intW = 0;if(typeof window.innerWidth == 'number' ) {
intH = window.innerHeight;
intW = window.innerWidth;
}
else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
intH = document.documentElement.clientHeight;
intW = document.documentElement.clientWidth;
}
else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
intH = document.body.clientHeight;
intW = document.body.clientWidth;
}
return { width: parseInt(intW), height: parseInt(intH) };
}function setLayerPosition() {
var shadow = document.getElementById('shadow');
var question = document.getElementById('question');var bws = getBrowserHeight();
shadow.style.width = bws.width + 'px';
shadow.style.height = bws.height + 'px';
question.style.left = parseInt((bws.width - 350) / 2)+ 'px';
question.style.top = parseInt((bws.height - 200) / 2)+ 'px';
shadow = null;
question = null;
} function showLayer() {
setLayerPosition();
var shadow = document.getElementById('shadow');
var question = document.getElementById('question');
shadow.style.display = 'block';
question.style.display = 'block';
shadow = null;
question = null;
}
function hideLayer() {
var shadow = document.getElementById('shadow');
var question = document.getElementById('question');
shadow.style.display = 'none';
question.style.display = 'none';
shadow = null;
question = null;
}function d(){
showLayer();
};
window.onload=function(){
window.onresize = setLayerPosition;
}
</script>
<a href="bg2.asp" target="mq" onclick="d()">测试一下 </a>
<table>
<tr>
<td width="864" valign="top">
<IFRAME marginWidth=0 marginHeight=0 frameBorder=no scrolling=auto name="mq" src="bg.htm" width=100% height=100%></IFRAME>
</td>
</tr>
<table>
<iframe id="shadow" class="opaqueLayer" style="border:0;" src="about:blank"></iframe>
<input type="button" value="click" onclick=";">
<div id="question" style="width:240px;height:80px;padding:0px;display:none;position:absolute;z-index:1001;background:#CCC;border:10px solid #999;">
正在加载....
</div>
bg2.aspwindow.onload=function(){
parent.hideLayer();
}