use this instead: alert(document.getElementById("i_n_content").document.body.value); alert(document.getElementById("i_n_content").document.body.outerHTML); alert(document.getElementById("i_n_content").document.body.innerHTML);
use this instead: alert(document.getElementById("i_n_content").document.body.value); alert(document.getElementById("i_n_content").document.body.outerHTML); alert(document.getElementById("i_n_content").document.body.innerHTML);
<asp:Button ID="btn_fileupload" runat="server" OnClick="btn_fileupload_Click" Text="上传图片" /><br /> <INPUT type="submit" value="添加" id="Submit1"><INPUT type="reset" value="重写"><input id="back" type="button" value="返回" language="javascript" onclick="history.back();" /></form> <script language="javascript"> i_n_content.document.designMode='on'; </script> </body> </HTML>del.aspx.cs *****************************************using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; using System.Text.RegularExpressions; using System.IO; public partial class del : System.Web.UI.Page {
alert(document.getElementById("i_n_content").document.body.outerHTML);
alert(document.getElementById("i_n_content").document.body.innerHTML);
alert(document.getElementById("i_n_content").document.body.outerHTML);
alert(document.getElementById("i_n_content").document.body.innerHTML);
alert(document.Form1.frames["i_n_content"].document.body.value);
alert(document.Form1.frames["i_n_content"].document.body.outerHTML);
alert(document.Form1.frames["i_n_content"].document.body.innerHTML);。。}
*********************************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="del.aspx.cs" Inherits="del" %><!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">
window.onunload=function()
{
setCookie("content",frames["i_n_content"].document.body.outerHTML);
alert(frames["i_n_content"].document.body.text);
}
function setCookie(name,value)
{
document.cookie = name + "="+ escape (value) + ";";}
function content_upload(vfilename)
{
window.i_n_content.focus();
alert(document.Form1.frames["i_n_content"].document.body.value);
alert(document.Form1.frames["i_n_content"].document.body.outerHTML);
alert(document.Form1.frames["i_n_content"].document.body.innerHTML);
var ncontent=frames["i_n_content"].document.body.innerHTML+"<img src="+vfilename+" unselectable=\'on\' ></img>";
alert(ncontent);
frames["i_n_content"].document.body.value=ncontent;
frames["i_n_content"].innerHTML=frames["i_n_content"].document.body.value;
alert("last="+frames["i_n_content"].innerHTML);
}
function map_upload()
{
} function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)) return unescape(arr[2]);
else return "";
}
</script>
</head>
<body topmargin="0" class="body" >
<form name="form1" method="post" action="ST_save.aspx" enctype="multipart/form-data" runat="server" id="Form1">
<br />
<iframe id="i_n_content" name="i_n_content" onload="this.contentWindow.document.body.innerHTML=getCookie('content');" ></iframe>
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btn_fileupload" runat="server" OnClick="btn_fileupload_Click" Text="上传图片" /><br />
<INPUT type="submit" value="添加" id="Submit1"><INPUT type="reset" value="重写"><input id="back" type="button" value="返回" language="javascript" onclick="history.back();" /></form>
<script language="javascript">
i_n_content.document.designMode='on';
</script>
</body>
</HTML>del.aspx.cs
*****************************************using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Text.RegularExpressions;
using System.IO;
public partial class del : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
protected void btn_fileupload_Click(object sender, EventArgs e)
{
Page.RegisterStartupScript("upload","<script>content_upload('"+FileUpload1.FileName+"')</script>");
}
}
帮忙改改吧。上面的都试了。