我用iframe嵌套一个页面,主要是为了实现Ajax上传的功能,页面代码如下:
- HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditAdProcLinkInfo.aspx.cs" Inherits="EnMng_SProMng_Page_Ad_EditAdProcLinkInfo" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title><script language="javascript" type="text/javascript">// <!CDATA[function uploadFile(){ alert("ok"); if(document.readyState == "complete" && ifu.document.readyState == "complete"){ //ifu.document.form1.submit(); var obj = document.frames[0]; obj.document.getElementById("btnSubmit").click(); } else { alert("sdfsd"); } }function btnSave_onclick() { if(document.getElementById("txtUrl").value == "") { alert("请输入链接地址!"); return false; } if(document.getElementById("filePic").value == "") { alert("请选择图片路径!"); return false; } if(document.getElementById("fileFlash").value == "") { alert("请选择Flash路径!"); return false; } uploadFile(); return false; //<%=Page.ClientScript.GetCallbackEventReference(this, string.Empty, "getSaveCalBack", string.Empty) %>;}function getSaveCalBack(str){ alert(str);}function btnCancle_onclick() {window.parent.parent.GB_hide();}// ]]></script></head><body > <form id="form1" runat="server"> <div> <div > <table style="width: 100%; height: 100%"> <tr> <td style="height: 22px" > 企业代码:</td> <td style="height: 22px" > <input type="text" id="txtCid" name="txtCid" readonly="readOnly" value ="<%= cid %>" /> </td> <td style="height: 22px" > 产品代码:</td> <td style="height: 22px" > <input type="text" id="txtPsid" name="txtPsid" readonly="readOnly" value="<%= psid %>" /> </td> </tr> <tr> <td style="height: 50px" > 链接地址:</td> <td style="height: 50px" > <input type="text" id="txtUrl" name="txtUrl" /><span style="color:Red;">*</span> </td> <td style="height: 50px" > 链接图片:</td> <td style="height: 50px" > <input type="text" id="filePic" readonly ="readonly" /> <input type="button" value="浏览..." onclick="javascript:filePic.value=ifu.getLoadUrl();" /> <span style="color:Red;">*</span> </td> </tr> <tr> <td style="height: 50px" > 链接Flash:</td> <td style="height: 50px" > <input type="text" id="fileFlash" readonly="readonly"/> <input type="button" value="浏览..." onclick="javascript:fileFlash.value=ifu.getLoadUrl();" /> <span style="color:Red;">*</span> </td> <td style="height: 50px" > </td> <td style="height: 50px" > </td> </tr> <tr> <td style="height: 50px" > </td> <td style="height: 50px" > <input type="button" value="确 定" id="btnSave" onclick="return btnSave_onclick()" /> <input type="button" value="取 消" id="btnCancle" onclick="return btnCancle_onclick()" /> </td> <td style="height: 50px" > </td> <td style="height: 50px" > </td> </tr> </table> </div> </div> <iframe src="Upload.aspx" frameborder="0" id="ifu" name="ifu" style="width: 577px; height: 58px"></iframe> </form></body></html>