有没有办法在mootools中捕获x浏览器粘贴事件?

发布于 2024-08-19 21:30:58 字数 65 浏览 4 评论 0原文

我想捕获用户何时使用 mootools 事件系统将数据粘贴到文本输入字段中。

有人有这方面的经验吗?

I want to capture when a user pastes data into a text input field using mootools event system.

Anyone have experience of this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

琉璃梦幻 2024-08-26 21:30:58

最近,paste 事件得到了更好的支持:IE 从 2000 年左右开始就有它(我认为是 IE 5.5),Firefox 从 3.0 开始就有它,WebKit 已经有几年了(不确定具体时间)。您应该尽可能使用它,并在其他情况下回退到检测 ctrl-v 或 shift-ins,或者使用计时器轮询输入框的值。

The paste event has become better supported in recent times: IE has had it since around 2000 (IE 5.5, I think), Firefox since 3.0, WebKit for a couple of years (not sure exactly when). You should use it where possible and fall back to detecting ctrl-v or shift-ins in other cases, or polling the input box's value using a timer.

肤浅与狂妄 2024-08-26 21:30:58

只要按下“ctrl+v”键,该函数就会被触发。

Mootools 文档: http://www.mootools.net/docs/more/Interface/Keyboard

编辑:HTML 和 JS 代码

<html>
    <head>
        <script type='text/javascript' src='core.js'></script>
        <script type='text/javascript' src='more.js'></script>
        <script type='text/javascript'>
        function keyPressed(e)
        {
            var evt = Event(e);
            evt.stop();
        }

        window.addEvent('domready', function()
        {
            var myKeyboardEvents = new Keyboard(
            {
                eventType: 'keyup', 
                events: 
                { 
                    'ctrl+v': keyPressed
                }
            });

            myKeyboardEvents.activate()

        });
        </script>
    </head>
    <body>
        <form id='myForm'>
            <input type='text' name='some' id='username' value='[email protected]'/>
        </form>
    </body>
</html>

The function will get fired whenever the keys 'ctrl+v' are pressed.

Mootools docs : http://www.mootools.net/docs/more/Interface/Keyboard

EDIT : HTML and JS Code

<html>
    <head>
        <script type='text/javascript' src='core.js'></script>
        <script type='text/javascript' src='more.js'></script>
        <script type='text/javascript'>
        function keyPressed(e)
        {
            var evt = Event(e);
            evt.stop();
        }

        window.addEvent('domready', function()
        {
            var myKeyboardEvents = new Keyboard(
            {
                eventType: 'keyup', 
                events: 
                { 
                    'ctrl+v': keyPressed
                }
            });

            myKeyboardEvents.activate()

        });
        </script>
    </head>
    <body>
        <form id='myForm'>
            <input type='text' name='some' id='username' value='[email protected]'/>
        </form>
    </body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文