var currentHTML=““; // 编辑iframe 里的HTML 代码
function Window_OnLoad() {
var MenuItems = new Array(12);
MenuItems[0] = “剪切“;
MenuItems[1] = “DoCut“;
MenuItems[2] = “复制“;
MenuItems[3] = “DoCopy“;
MenuItems[4] = “粘贴“;
MenuItems[5] = “DoPaste“;
MenuItems[6] = “全选“;
MenuItems[7] = “DoSelectAll“;
window.external.setContextMenu(MenuItems);
}
function DoCut() {
target.document.execCommand(“Cut“, false, null);
target.focus();
}
function DoCopy() {
target.document.execCommand(“Copy“, false, null);
}
function DoPaste() {
target.document.execCommand(“Paste“, false, null);
}
function DoSelectAll() {
target.document.execCommand(“SelectAll“, false, null);
}
function GetContents() {
if (target.document.all[“cdiv“]!=null) return target.document.all[“cdiv“].innerHTML;
else return target.document.body.innerHTML;
}
/*
function GetOritext(){
if (target.document.all[“ori“]!=null) return target.document.all[“ori“].innerText;
else return null;
}
function GetPlainContents()
{
if (target.document.all[“cdiv“]!=null) return target.document.all[“cdiv“].innerText;
else return target.document.body.innerText;
}
function GetAllPlainContents()
{
return target.document.body.innerText;
}
*/
function PutContents(contents)
{
targetDoc.designMode = “On“;
if (target.document.all[“cdiv“]!=null){
target.document.all[“cdiv“].innerHTML = contents;
}else{
target.document.body.innerHTML = contents;
}
}
function cleanHtml() {
var fonts = target.document.body.all.tags(“FONT“);
var curr;
for (var i = fonts.length - 1; i >= 0; i--) {
curr = fonts[i];
if (curr.style.backgroundColor == “#ffffff“) curr.outerHTML = curr.innerHTML;
}
}
function setMode(newMode) {
bTextMode = newMode;
var cont;
if (bTextMode) {
cleanHtml();
cleanHtml();
function onBlank()
{
if(targetDoc.body.innerHTML!=“<PRE></PRE>“){
if(confirm(“你确认清除当前编辑内容吗?“)){
PutContents(top.text)
}
}
}
function onSave()
{
top.HTML = targetDoc.body.innerHTML;
alert(top.HTML);
}
function onFontName(value)
{
targetDoc.execCommand(''FontName'', '''', value);
target.focus();
}
function onFontSize(value)
{
targetDoc.execCommand(''FontSize'', '''', value);
target.focus();
}
function onColor(value)
{
targetDoc.execCommand(''forecolor'','''',value);
target.focus();
}
function onBKColor(value)
{
targetDoc.execCommand(''backcolor'','''',value);
target.focus();
}
function onBold()
{
targetDoc.execCommand(''Bold'');
target.focus();
}
function onItalic()
{
targetDoc.execCommand(''Italic'');
target.focus();
}
function onUnderLine()
{
targetDoc.execCommand(''Underline'');
target.focus();
}
function onALeft()
{
targetDoc.execCommand(''JustifyLeft'');
target.focus();
}
function onACenter()
{
targetDoc.execCommand(''JustifyCenter'');
target.focus();
}
function onARight()
{
targetDoc.execCommand(''JustifyRight'');
target.focus();
}
function onNList()
{
targetDoc.execCommand(''InsertOrderedList'');
target.focus();
}
function onBList()
{
targetDoc.execCommand(''InsertUnorderedList'');
target.focus();
}
function onOutDent()
{
targetDoc.execCommand(''Outdent'');
target.focus();
}
function onInDent()
{
targetDoc.execCommand(''Indent'');
target.focus();
}
function getElem(sTag,start)
{
while ((start != null) && (start.tagName != sTag)) start = start.parentElement;
return start;
}
function onHyperLink()
{
if(targetDoc.selection.type==“Control“){
return;
};
target.focus();
var DoA = getElem(“A“,targetDoc.selection.createRange().parentElement());
var str = prompt(“请输入超链接地址(例如http://www.sohu.com):“, DoA ? DoA.href : “http:\/\/“);
if ((str != null) && (str != “http://“))
{
if (targetDoc.selection.type == “None“)
{
var sel = targetDoc.selection.createRange();
sel.pasteHTML(“<A HREF=\““+str+“\“>“+str+“</A> “);
sel.select();
}
else
{
targetDoc.execCommand(''CreateLink'','''',str);
}
}
else target.focus();
}
function onImage()
{
if(targetDoc.selection.type==“Control“){
return;
};
target.focus();
var DoA = getElem(“A“,targetDoc.selection.createRange().parentElement());
var str = prompt(“输入图片的超链接(例如http://images.sohu.com/soh1.gif):“,DoA ? DoA.href : “http:\/\/“);
if ((str != null) && (str != “http://“))
{
if (targetDoc.selection.type == “None“)
{
var sel = targetDoc.selection.createRange();
sel.pasteHTML(“<img src=\““+str+“\“>“);
sel.select();
}
else
{
targetDoc.execCommand(''InsertImage'','''',str);
}
}
else target.focus();
}
function onEmotion(str)
{
if(targetDoc.selection.type==“Control“){
return;
};
if ((str != null))
{
target.focus();
if (targetDoc.selection.type == “None“)
{
var sel = targetDoc.selection.createRange();
sel.pasteHTML(str);
sel.select();
}
else
{
var sel = targetDoc.selection.createRange();
sel.pasteHTML(str);
}
}
else target.focus();
}
</script>
<script LANGUAGE=“Javascript“ SRC=“http://images.chinaren.com/product/alumni/htmledit/Html_Editor.js“>
</script>
<script>
var targetDoc = document.frames.target.document;
targetDoc.designMode = “On“;
//target.focus();
var oFunName = ““;
var bDialogStatus = false;
function fnCallDialog(val)
{
oFunName = val;
showModelessDialog(“colorchange.html“,window,“status:false;dialogLeft:“+event.screenX+“;dialogTop:“+event.screenY+“;dialogWidth:130px;dialogHeight:150px;edge:raised;help:off;status:off;scroll:off“);
}
var emotion=““;
function ShowEmotion(){
showModelessDialog(“emotion.html“,window,“status:false;dialogLeft:“+event.screenX+“;dialogTop:“+event.screenY+“;dialogWidth:210px;dialogHeight:210px;edge:raised;help:off;status:off;scroll:off“);
}
function ShowTable(){
showModelessDialog(“table.html“,window,“status:false;dialogLeft:“+event.screenX+“;dialogTop:“+event.screenY+“;dialogWidth:340px;dialogHeight:220px;edge:raised;help:off;status:off;scroll:off“);
}
function addMonitor(){
targetDoc.async = false;
if(targetDoc.readyState!=“complete“){
window.setTimeout(“addMonitor()“,200);
}else{
targetDoc.attachEvent(''oncontrolselect'',doFocusObj);
}
}
function doFocusObj(){}
addMonitor();