将事件附加到具有文本类型“增强富文本”的 Sharepoint 多行文本框
我必须将 OnKeyPress
事件附加到 文本类型为“增强富文本”的 SharePoint 多行列。以下是我正在使用的 jscript 代码,
<script>
var ele=document.getElementById(inpID);
if(ele!=null){
ele.onkeypress=function(){calLen(this);};
}
function calLen(obj)
{
if(obj.value.length>=5){
alert('Cannot exceed character limit 5');
obj.value=obj.value.substring(0,5);
}
</script>
但事件未附加。
使用 SharePoint 多行文本框文本类型为“纯文本”,一切正常。
有人可以帮我解决这个问题吗...?
I have to attach OnKeyPress
event to the SharePoint multi-line column with text type as "Enhance Rich Text". Following is the jscript code that I am using
<script>
var ele=document.getElementById(inpID);
if(ele!=null){
ele.onkeypress=function(){calLen(this);};
}
function calLen(obj)
{
if(obj.value.length>=5){
alert('Cannot exceed character limit 5');
obj.value=obj.value.substring(0,5);
}
</script>
But the event is not getting attached.
The things are working fine with SharePoint Multi-line TextBox with Text Type as "Plain Text".
Can some one help me to solve this issue...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
增强型富文本字段不会呈现为任何类型的标准
FORM
控件(例如,简单的TEXTAREA
)。它们是复杂的控件,其中包括可以显示 HTML 内容预览的IFRAME
。我建议使用 Internet Explorer 的 开发人员工具栏(或者更好的是,Firebug for Mozilla Firefox)深入了解 ERT“控件”弄清楚您可以绑定哪些子组件。
此外,某些事件(例如
onkeypress
)完全有可能已在 ERT 内部处理,因此永远不会冒泡,以便您可以处理它们。如果您正在为 ERT 使用替换组件(尤其是 Telerik 的 RADEditor),可能有一些已实现并且您可以绑定到的自定义事件。
Enhanced Rich Text fields are not rendered as any sort of standard
FORM
control (like, for instance, a simpleTEXTAREA
). They are complex controls comprised of, among other things, anIFRAME
that can display your HTML content preview.I recommend using Internet Explorer's Developer Toolbar (or even better, Firebug for Mozilla Firefox) to drill in to the E.R.T. "control" and figure out what subcomponents you could bind to.
Also, it's entirely possible that some events, like
onkeypress
, are already being handled internally to the E.R.T. and thus will never bubble up so that you can handle them.If you're using a replacement component for your E.R.T. (esp. Telerik's RADEditor), there may be some custom events that have been implemented and to which you could bind to.