您的位置:首页 > Web前端 > JavaScript

点击框架结构左侧内容后,添加到右边指定的文本域中的JS代码

2014-11-28 09:09 288 查看
function MM_findObj(n, d) { //v4.01
var p,i,x;
if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d
)&&d.all) x=d.all
; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i]
;
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
var obj = MM_findObj(objName);
if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
if (theValue == true || theValue == false)
eval("obj."+theProp+"="+theValue);
else eval("obj."+theProp+"='"+theValue+"'");
}
if (parent.frames["<strong><span style="color:#ff0000;">mainFrame</span></strong>"].document.getElementById("checkbox2").checked==false)
{
parent.frames["<span style="color:#ff0000;"><strong>mainFrame</strong></span>"].document.getElementById("checkbox2").click();
<!-- mainFrame这个名称一定要和第57行中?号后面的那个名称一样,还要跟ybcx.html中的第8行<frame name="mainFrame" src="ybcx.htm" />中的name一样,否则无法传递点击的值  ->
}
}


<a href="#" class="style5" onClick="MM_changeProp('textfield3?mainFrame','','value','xxxxxxxxxxxxx','INPUT/TEXT')">xxxxxxxxxxxxxx</a>

ybcx.html中的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xxxxxxxxxx</title></head>
<frameset rows="*" cols="300,*">
<frame name="left" src="left.htm"  noresize="noresize" />
<frame name="<strong><span style="color:#ff0000;"><strong><span style="color:#ff0000;">mainFrame</span></strong></span></strong>" src="ybcx.htm" />
</frameset>
<noframes><body>
</body></noframes>
</html>


上面三处对框架窗口中,右边那个窗口的名称一定要一致,否则无法实现将左侧点击后的内容放到右边指定地方
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: