将事件附加到具有文本类型“增强富文本”的 Sharepoint 多行文本框

发布于 2024-09-02 15:57:54 字数 536 浏览 2 评论 0原文

我必须将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虐人心 2024-09-09 15:57:54

增强型富文本字段不会呈现为任何类型的标准 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 simple TEXTAREA). They are complex controls comprised of, among other things, an IFRAME 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文