直接看代码:
<div id="win" > </div> <a οnclick="showWindow('xxx','photosNames','photos','photos_up_file','2')" class="easyui-linkbutton">上传</a> 方法showWindow() function showWindow(names,upName,upUrl,upA,upType){ $('#win').window({ width:600, height:350, modal:true, closed:true, title:names, maximizable:false }); $("#win").window('open'); /* $("#win").html('<div id="centers" style="width:600px,height:400px" ></div>'); */ $("#win").html("<iframe id='son' src='upload_child.html' allowTransparency='true' style='border:0;width:98%;height:98%;padding-left:2px;' frameBorder='0'></iframe>"); assgVal(upName,upUrl,upA,upType); } function assgVal(upName,upUrl,upA,upType){ setTimeout(function () { //直接操作子页面属性,给子页面的 $('#son').contents().find("#name").val(upName); $('#son').contents().find("#url").val(upUrl); $('#son').contents().find("#a").val(upA); $('#son').contents().find("#type").val(upType); },200); } upload_child.html 子页面 <input type="hidden" id = "url" /> <input type="hidden" id = "name" /> <input type="hidden" id = "a" /> <input type="hidden" id = "type" value="1"/> /*给父对象赋值 */ function sumValue(names,url){ window.parent.$("#"+fileName+"").val(names); window.parent.$("#"+fileUrl+"").val(url); }