【发布时间】:2012-04-02 22:40:32
【问题描述】:
我在 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 复制到隐藏的值始终为空“”。
【问题讨论】:
标签: javascript asp.net asp.net-mvc-3 iframe