日期:2014-05-16  浏览次数:20292 次

iframe为父页面的FORM添加事件如何实现
如题
---------------父页面----------------    
<body>
        <form   action= " "   id= "form1 "   >
        <iframe   src= "edit.html?cid=content&fid=form1 "   width= "100% "   height= "300px "> </iframe>
        <textarea   rows= "10 "   cols= "50 "   name= "content "   id= "content "> </textarea>
        <input   type= "submit "   />
        </form>
    </body>

----------------了页面-------------------
function   init()
{
f   =   parent.document.getElementById(getArgs( "fid "));
//f是父页面的FORM结点.
//如何为f增加一个onSubmit事件?
}



------解决方案--------------------
function init()
{
f = opener.document.getElementById( "form1 ");
//f是父页面的FORM结点.
//如何为f增加一个onSubmit事件?
f.onsubmit=function (){alert( "onSubmit事件 ");};
}