1
私はasp.net mvc 3のiframeを使ってエディタを作成しています。これは動作していません。asp.net mvc 3のiframeを使ってエディタを作成する
これはjavascriptのである:
$(document).ready(function() {
document.getElementById('textEditor').contentWindow.document.designMode = "on";
document.getElementById('textEditor').contentWindow.document.close();
$("#save").click(function() {
alert('ooosooooo');
if ($(this).hasClass("selected")) {
$(this).removeClass("selected");
} else {
$(this).addClass("selected");
}
on();
});
});
function on() {
var edit = document.getElementById("textEditor").contentWindow;
edit.focus();
//edit.document.execCommand('SaveAs', '1', 'e:\');
//edit.document.execCommand('foreColor', false, "#000000");
var ifi = document.getElementById('textEditor');
alert('ifi.innerHTML');
alert(ifi.innerHTML);
alert($("#textEditor").html());
//Trying to copy the content of text editor t hidden
//not working its always empty the textEditor
$("#hidden_field_id").val($("#textEditor").html());
edit.focus();
}
これはhtmlです:
@using (Html.BeginForm("Save", "Home", FormMethod.Post, new { enctype = "multipart/form-data", target="textEditor"}))
{
@*this is the iframe*@
<iframe id="textEditor" name="textEditor" width="100%" height="500px"></iframe>
<input type="hidden" id="hidden_field_id" name="hidden_field_id" value="ww"/>
<input type="submit" id="save" class="save" value="send" />
}
問題は、私はからコピーされた値を保存/送信を押したとき、私は、テキストエディタにテキストを挿入するときということです隠されたiframeは常に空 ""です。