//--------------------子窗口--------------------------------------// <html> <head> <script language=javascript> var rFrame; var rFrameDoc; var rForm;//------------ getFrame() //------------ Get references to objects in right frame function getFrame() { rFrame = self.opener; rFrameDoc = rFrame.document; rForm = rFrameDoc.globe; }//------------ failOpt() //------------ Reproduces failure function failOpt(elName,inText,inValue) { alert("ssss"); //Get a reference to select box in the other frame var rSel = rForm(elName);//Create a new Option in this frame var myOpt = new Option(inText,inValue)//add option from this frame to select box in other frame alert("Check the select box to see if any item was added."); rSel.options[rSel.length] = myOpt; }</script></head> <body onload="getFrame()"> 添加单位成功! <input type=button name=trigger1 value="Reproduce Problem" onclick="failOpt( 'pwork','11111','11' );"> </body> </html> //--------------------------------父窗口------------------------// <html> <head> <script> function songScript1(url) { var Win = window.open(url,"songScript1",'width=440,height=260,resizable=0,scrollbars=no,menubar=no,status=no' ); } function newOpt(inText,inValue) { function newOpt(inText,inValue) { // Create element in this frame's tree var myOpt = new Option(inText,inValue)// return reference return myOpt }</script> </head> <body> <form name="globe"><select name="pwork"></select></form><a href="javascript:songScript1('addwork.php')">添加</a> </body> </html> 代码好像有错误?
pwork 是个下拉框,我想在子页面中往父页面的pwork 下拉框中加"姓名" value="1"请问怎么加?
<script>
var str="<select name='pwork'><option value='1'>姓名</option></select>"
window.opener.document.globe.pwork.outerHTML=str;
</script>
</body>
<html>
<head>
<script language=javascript>
var rFrame;
var rFrameDoc;
var rForm;//------------ getFrame()
//------------ Get references to objects in right frame
function getFrame()
{
rFrame = self.opener;
rFrameDoc = rFrame.document;
rForm = rFrameDoc.globe;
}//------------ failOpt()
//------------ Reproduces failure
function failOpt(elName,inText,inValue)
{
alert("ssss");
//Get a reference to select box in the other frame
var rSel = rForm(elName);//Create a new Option in this frame
var myOpt = new Option(inText,inValue)//add option from this frame to select box in other frame
alert("Check the select box to see if any item was added.");
rSel.options[rSel.length] = myOpt;
}</script></head>
<body onload="getFrame()">
添加单位成功!
<input type=button name=trigger1 value="Reproduce Problem"
onclick="failOpt( 'pwork','11111','11' );">
</body>
</html>
//--------------------------------父窗口------------------------//
<html>
<head>
<script>
function songScript1(url)
{
var Win = window.open(url,"songScript1",'width=440,height=260,resizable=0,scrollbars=no,menubar=no,status=no' );
}
function newOpt(inText,inValue)
{
function newOpt(inText,inValue)
{
// Create element in this frame's tree
var myOpt = new Option(inText,inValue)// return reference
return myOpt
}</script>
</head>
<body>
<form name="globe"><select name="pwork"></select></form><a href="javascript:songScript1('addwork.php')">添加</a>
</body>
</html>
代码好像有错误?