前端:
<iframe id="iframe1"></iframe>
var tr = $("#div2_2_tbody").find("tr");
var jc = 0;
var td11 = "";
var td91 = "";
var td141 = "";
for (var i = 0; i < tr.length; i++) {
var td = $(tr.eq(i)).find("td");
var td1 = $(td.eq(1)).text();
var td9 = $(td.eq(9)).find("input").eq(0).val();
var td14 = $(td.eq(14)).find("input").eq(0).val();
td1 = td1.replace('|', '');
td9 = td9.replace('|', '');
td14 = td14.replace('|', '');
td11 = td11 + td1 + "|";
td91 = td91 + td9 + "|";
td141 = td141 + td14 + "|";
}
var s = ""
+ "<"
+"/script>"
+ "<div> <form id='form1' method='post' action='../Home/fpgl4_form_tj' enctype='multipart/form-data' > <input type='text' name='id1' value='" + td11+"' />"
+ " <input type='text' name='ysdh' value='" + td91+"' />"
+ " <input type='text' name='bz' value='" + td141 +"'/>"
+" </form> </div>"
+ "<script type='text/javascript'> "
+ " $(function(){ $('#form1').submit(); });</"
+ "script>";
$("#iframe1").contents().find('body').html(s);
$("#iframe1").contents().find('body').find("form").submit();
//返回的函数
function frame_t(a) {
alert(a);
if (a == "保存成功!") {
fh1();
}
}
后台:
public string fpgl4_form_tj(string id1, string ysdh, string bz)
{
string r1 ="";// "<script type='text/javascript'> parent.parent.frame_t('xxxx');</script>";
return r1;
}
html:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2 id="jg1">@ViewData["jg"]</h2>
<script type="text/javascript">
function tz() {
var jg1 = $("#jg1").html();
parent.frame_t(jg1);
}
$(function () {
setTimeout("tz()", 1000);
});
</script>