- 热门文章:
- · 滚动条颜色生成器IE5.5+
- · 设置open方法中的参数
- · 打开页面就是全屏的方法
- · javascript 实现下拉列表连动,提示:Array not defined
- · 利用javascript实现时间段的查询
- · 表单填写时用 回车 代替 TAB 的实现方式
- · javascript里类似select case 该如何用?
- · javascript里类似select case 该如何用?
- · 在javascript 里面有没有检查日期格式的函数?
- · js中with的和case的用法
- · asp的cookie本身不设置的话默认的是application的path=/,所以不设关系不大,expires要设。给你netscape...
- · html的标准里这样写的。
上一篇:ASCII 字形生成器 >>
IE 5.5 的内置编辑器(在MSDN ONLINE翻出来的资料)
<HTML>
<HEAD>
<TITLE>Editable Regions Sample</TITLE>
<STYLE>
BODY{margin:0;
background:white;
font-family:verdana;
font-size:80%;}
BUTTON {cursor:hand;
background:#ffffff;
border-color:#99ccff;
font-weight:bold;}
.bar{background:#336699;
width:100%;
height:30px;
border-top:1px solid #99CCFF;
border-bottom:1px solid #000000;}
.desbar{background:#FFFFFF;
width:100%;
padding: 10px;
border-top:1px solid #CCCCCC;
border-bottom:1px solid #000000;
color:black;
font-size:8pt;
height:105;}
.title{font-size:15pt;
color:white;
padding-left:10px;}
.bar A:link {text-decoration:none; color:white}
.bar A:visited {text-decoration:none; color:white}
.bar A:active {text-decoration:none; color:white}
.bar A:hover {text-decoration:none; color:yellow}
</STYLE>
<SCRIPT>
<!-- The fnInit function initializes the editable and non-editable regions -->
<!-- of the document -->
function fnInit(){
<!-- Ensure the display interface is not selectable, by making all -->
<!-- elements UNSELECTABLE -->
for (i=0; i<document.all.length; i++)
document.all(i).unselectable = "on";
<!-- Prepare the editable regions -->
oDiv.unselectable = "off";
oTextarea.unselectable = "off";
}
<!-- The fnToggleEdits function turns editing on or off in the editable -->
<!-- regions of the document -->
function fnToggleEdits(oObj,oBtn) {
currentState = oObj.isContentEditable;
newState = !currentState;
oObj.contentEditable = newState;
newState==false ? oBtn.innerHTML=@#Turn Editing On@# :
oBtn.innerHTML=@#Turn Editing Off@#;
}
</SCRIPT>
</HEAD>
<BODY onload="fnInit();">
<!-- TOOLBAR_START --><!-- TOOLBAR_EXEMPT --><!-- TOOLBAR_END -->
<DIV CLASS="bar title">Editable Regions Sample</DIV>
<DIV CLASS="desbar">
<H4 style="font-size:10pt;">This example demonstrates the features of
Microsoft® Internet Explorer that enable users to edit the content
of an HTML element directly from the browser.</H4>
<P>This HTML editor is a <B>DIV</B> element set to be content-editable. Any
valid HTML content (text, images, form controls, etc.) can be pasted
and edited in this editor.</P>
<DIV ALIGN="center">
<DIV ALIGN="center" STYLE="height:210; width:90%;
background-color:#99CCFF; border:1px solid black">
<DIV CLASS="bar title">HTMLEditor (Content-Editable DIV)</DIV>
<DIV style="padding:10px">
<BUTTON ID="oEditDiv" TITLE="Turn Editing Off"
onclick=@#fnToggleEdits(oDiv,oEditDiv);oDiv.focus();@#>
Turn Editing Off</BUTTON>
<BUTTON ID="oBoldBtn" TITLE="Bold"
onclick=@#if (oDiv.isContentEditable==true)
document.execCommand("Bold");@#><B>Bold</B></BUTTON>
<BUTTON ID="oItalicBtn" TITLE="Italic"
onclick=@#if (oDiv.isContentEditable==true)
document.execCommand("Italic");@#><I>Italic</I></BUTTON>
<BUTTON ID="oUndLnBtn" TITLE="Underline"
onclick=@#if (oDiv.isContentEditable==true)
document.execCommand("Underline");@#><U>Underline</U></BUTTON>
<BUTTON ID="CreateLink " TITLE="Underline"
onclick=@#if (oDiv.isContentEditable==true)
document.execCommand("CreateLink");@#><U>CreateLink</U></BUTTON>
<BUTTON ID="CreateLink " TITLE="Underline"
onclick=@#if (oDiv.isContentEditable==true)
document.execCommand("InsertImage","xx");@#><U>InsertImage</U></BUTTON>
</DIV>
<DIV id=oDiv CONTENTEDITABLE ALIGN=left STYLE="height:100;
width:95%;background-color:white; font-face:Arial; padding:3;
border:inset #99ccff; scrollbar-base-color:#99ccff;
overflow=auto;"></DIV>
<BUTTON TITLE="Append from HTMLEditor"
onclick=@#oTextarea.value+=oDiv.innerHTML;oTextarea.focus();@#>
Append to TextEditor</BUTTON>
</DIV>
</DIV>
<P>This text editor is a <B>TEXTAREA</B> element and is content-editable by
default. Only text can be edited in this tool. However, you can draft
HTML in the TEXTEditor and press the <B>Append to HTMLEditor</B> button
to see the result appended to HTMLEditor. The <B>Append to
TextEditor</B> button reverses this process by appending the
HTMLEditor@#s HTML as text to the TEXTEditor.
</P>
<BR/>
<DIV ALIGN="center">
<DIV ALIGN="center" STYLE="height:210; width:90%;
background-color:#99ccff; border:1px solid black">
<DIV CLASS="bar title">TEXTEditor (TEXTAREA)</DIV>
<DIV style="padding:10">
<BUTTON ID="oEditText" TITLE="Turn Editing Off"
onclick=@#fnToggleEdits(oTextarea,oEditText);
oTextarea.focus();@#>Turn Editing Off</BUTTON>
</DIV>
<TEXTAREA id=oTextarea ALIGN=left STYLE="height:100; width:95%;
background-color:white; padding:3; border:inset #99ccff;
scrollbar-base-color:#99ccff; overflow=auto;"></TEXTAREA><BR/>
<BUTTON TITLE="Append to HTMLEditor"
onclick=@#oDiv.innerHTML+=oTextarea.value;oTextarea.focus();@#>
Append to HTMLEditor</BUTTON>
</DIV>
</DIV>
<BR/>
<P>Both editors use the same function to activate or deactivate editing.
The function uses the <B>isContentEditable</B> property to test whether
editing is active. Accordingly, the <B>contentEditable</B> property is
then reversed to reset editing.</P>
</DIV>
<DIV CLASS="bar" STYLE=" padding:5px; padding-left:10">
<A href="http://www.microsoft.com/misc/cpyright.htm" target=_top>
©2001 Microsoft Corporation. All rights reserved. Terms of use.</A>
</DIV>
</body>
</html>
上面的例子我加了两个按钮,原例见:
http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/editRegions.htm
参考:
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/contentEditable.asp
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/execCommand.asp
http://msdn.microsoft.com/workshop/author/dhtml/reference/commandids.asp
下一篇:滚动条颜色生成器IE5.5+ >>
相关文章:
- · Dreamweaver 4 & UltraDev 4两个BUG(字体设置不能保存和行号显示错位)的解决方法
- · 一个DHTML的例子——3D文字
- · 如何做页面自动刷新,又不用让用户按回车键来提交数据!(大功告成)
- · javascript对象与数组参考大全1
- · javascript对象与数组参考大全2
- · 一个点击后自动滚屏的例子!
- · 一个鼠标自动移动的js例子!
- · window.showModalDialog()中有三个参数,各有什么用,请举例!
- · 三级下拉框连动的数据库版!
- · 给一个类增加属性和方法?看看这个够不够?
- · 在网页中实现OICQ里的头像选择的下拉框 (附例子)
- · 请看用javascript设置和读取cookie的简单例子.....
- · 请看被打开的子窗口继承父窗口定义的styleSheets的例子
- · 经常有人询问如何用javascript判断日期是否有效,我以前也遇到过,不过后来得高人指点解决了,贴出来大...
- · ShowModalDialog的具体用法
- · 下拉式互动列表框(EC潮流网同学录之真情留言板使用的代码)
- · MSGBOX返回值
- · js中几种去掉字串左右空格的方法,请看
- · VBSctipt 5.0中的新特性
- · Jscript 5.0中的新特性
- · 加快 DHTML 的一组技巧(Copy from Microsoft)
- · 一个不太让人讨厌的自动弹出窗口:)
- · 一个把数字转英文的实用程序
- · rollarea.js及其用法示例
- · 下拉框连动的小例子(.htm版)
- · 判断访问者的浏览器是否支持javascript和Cookies
- · 在Windows桌面上使用WSH接收邮件 (转)
- · HTML4.0的 Access Key
- · 绝对是好东西 (select1 <==> select2):
- · 一个类似vbscript的round函数的javascript函数
- · 用javascript检查yyyy-mm-dd格式的正确源码。
- · HEAD元素使用集锦 (转)
- · 脚本控制Frame (转)
- · vbscript错误代码及对应解释大全
- · jscript错误代码及相应解释大全
- · 打开最大化窗口的一点经验
- · 无偿贡献,进入页面后自动刷新一次
- · 庆祝 Joy ASP 上贴数超过800页!!! 送给大家一个小礼物 ^_^
