- 浏览: 401044 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
In the previous discussion about javascript - trigger event and custom events and javascript - trigger event and custom events, we talked about how to add/remove custom events and how to trigger them, we also discussed the how to detect if an event support bubbling in the post - javascript - trick to detect bubbling supportability;
This topic will address one of the event that does not bubble. In IE, the sumit event does not bubble, but fortunately, we can simulate the bubbling event for submit with custom event, and actually it will do a check, if the submit is supported in the end browser, we use the native one, otherwise, we hack it.
the rational behind the hack is that a submit event can be triggered by one of the two
- Clicking (or focusing on and hitting a trigger key, like enter or spacebar) a submit or image submit button.
- Pressing enter while inside a text or password input.
so below is the simulated addSubmit and removeSubmit definition.
/************************************** *@Name: addremoveevents.js * simulate a submit event in IE that has the bubbling ability *@Summary * *@NOTE: * to use this event, you will need the following dependencies. * 1. addremoveevents.js * 2. isEventSupported.js * @Usage * you can use the elem.addSumit and * @todo: * Test ***************************************/ (function () { // check to see if the submit event works as we expect it to if (!isEventSupported("submit")) { this.addSubmit = function (elem, fn) { // Still bind as normally addEvent(elem, "submit", fn); // But we need to add extra handlers if we 're not on a form // Only add the handlers for the first handler bound if (elem.nodeName.toLowerCase() !== "form" && getData(elem).events.submit.length === 1) { addEvent(elem, "click", submitClick); addEvent(elem, 'keypress', submitKeypress); } }; // this.removeSubmit = function (elem, fn) { removeEvent(elem, "submit", fn); var data = getData(elem); // Only remove the handler when there's nothing left to remove if (elem.nodeName.toLowerCase() !== "form" && !data || !data.events || !data.events.submit) { addEvent(elem, "click", submitClick); addEvent(elem, "keypress", submitKeypress); } }; // ohwrise the event works perfect fine // so we just behave normally } else { this.addSumit = function (elem, fn) { addEvent(elem, "submit", fn); }; this.removeSubmit = function (elem, fn) { removeEvent(elem, "submit", fn); }; } // We need to track clicks on elements that will submit the form // (submit button click and image button click function submitClick(e) { var elem = e.target, type = elem.type; if ((type === "text" || tpye === "image") && isInForm(elem)) { return triggerEvent(this, "submit"); } } // Additionally we need to track for when the enter key is hit on // text and password inputs (also submits the form) function submitKeypress(e) { var elem = e.target, type = elem.type; if ((type === "text" || type === "password") && isInForm(elem) && e.keyCode === 13) { return triggerEvent(this, "submit"); } } //We need to make sure that the input elements that we check // against are actually inside of a form function isInForm(elem) { var parent = elem.parentNode; while (parent) { if (parent.nodeName.toLowerCase() === "form") { return true; } parent = parent.parentNode; } return false; } })();
发表评论
-
javascript - trick to cross browser DOM ready event
2012-08-24 08:23 929the "ready" event ... -
javascript - trick to simulate mouseenter and mouseleave
2012-08-23 08:31 2255Previously we discussed javasc ... -
javascript - trick to simulate the change event
2012-08-22 08:51 1670In the previous discussion a ... -
javascript - trick to implement bubbling submit event
2012-08-23 07:55 706Following up to the javascrip ... -
javascript - trick to detect bubbling supportability
2012-08-20 22:22 974Event delegation is oe of the b ... -
javascript - trigger event and custom events
2012-08-20 21:58 2083In the previous post - javascri ... -
javascript - trick to handlers management
2012-08-20 08:19 1032We have discussed "javascr ... -
javascript - trick to centralized store
2012-08-20 07:52 822For a number of reasons it's ... -
javascript - trick to fix the event object
2012-08-20 07:47 885Many browsers, especially In ... -
javascript - tricks to deal with colors
2012-08-15 08:34 769There are a couple of ways to r ... -
javascript - trick to manipulate the opacity
2012-08-15 08:26 768All other browsre may have supp ... -
javascript - trick to test visibility of an element
2012-08-15 08:15 524though there is a visible prope ... -
javascript - trick to get and set height and width
2012-08-15 08:05 550when looking at properties t ... -
javascript - trick to set/get attributes that expects px values
2012-08-16 11:00 521When setting a number into a ... -
javascript - trick to get and set CSS style
2012-08-16 11:00 749while it will not be so much tr ... -
javascript - trick to normalize href for IE
2012-08-16 10:59 537IE is again the only browser th ... -
javascript - trick IE form and its expando attribute
2012-08-16 10:59 1043there is a known issue that if ... -
javascript expando and attributes
2012-08-14 08:15 1044expando is something like this ... -
javascript - trick to getText and setText
2012-08-14 07:40 1149it is not as simple as you thin ... -
javascript - trick/guideline to remove DOM element
2012-08-14 07:00 1182remove an element is not as sim ...
相关推荐
Pandas-and-NumPy-Tips-Trick-and-Techniques-master
在VB6(Visual Basic 6)中,"S-a-D-trick.rar_Join In" 这个主题涉及到的是文件分割与合并的技术。在处理大文件时,为了方便传输或者存储,我们可能会选择将其分割成多个小文件,而在需要使用整个文件时,则需要将...
Python-trick,上传的事pdf文档
在规定的时间内,使用鼠标控制帽子接住落下的保龄球,躲避炸弹。_Hat-Trick
【HLP-Trick-crx插件】是一款专为解决特定网页限制而设计的浏览器扩展程序,主要用于恢复用户在浏览网页时被禁用的复制、粘贴功能,以及上下文菜单和本地高亮显示功能。这款插件特别适用于那些因为版权保护或者安全...
语言:python 内容包括:源码、数据集、数据集描述、论文 目的:使用CNN算法在橄榄球比赛中目标检测。 带数据集很好运行,主页有搭建环境过程。主页有更多源码。 数据集描述如下: 在这场比赛中,你的任务是预测球员...
gtg-grind-trick-generator PWA Web应用程序(Node.js,JS,HTML,CSS) Chrome,Safari,Firefox,Edge(Android,iOS,MacOS,Windows) 离线工作Android应用程式使用Google Workbox,Webpack制作
Python 提示和技巧 ... git clone https://github.com/plasmashadow/py-trick-book.git 我假设您安装了 ipython 导航到目录并执行 ipython notebook 笔记: 退出间谍活动并自己阅读 或者 保持冷静,加入草帽海贼团
...DOCTYPE>声明、元素、元素和元素。<!...包含元数据,如标题()、字符集(<meta charset="UTF-8">)和链接外部资源(如CSS文件)。则包含网页的可见内容,如文本、图像、链接等。...例如,使用和来定义页面头部和底部,...
React 21 卡技巧一个演示卡片技巧的React应用程序。动机该项目旨在学习如何使用 React 钩子和进行嵌套的 api 调用。 该项目不再进行。怎么玩记住 21 张卡片中的 1 张后,单击完成。 选择您的卡片所在的 3 堆中的哪一...
Trick-CMCC 利用CMCC公共热点的小漏洞免费上网~~ :) sudo ./conn.sh Notice: 目前只知道我工CMCC有这特色, 其他地区尚不明确 Notice: 脚本适用于使用NetWorkManager网络sds管理工具的系统 Notice: 不必惊讶原理, ...
1. 下载最新版本的源代码,例如压缩包内的hattrick-0.1.6。 2. 在VDR环境中编译和安装插件。这可能需要熟悉Linux环境和基本的编译命令。 3. 配置VDR以启用Hattrick插件,并设置与Hattrick账户的连接信息。 4. 更新...
该扩展程序重新启用网页上的复制/粘贴功能,上下文菜单和本机突出显示功能。 支持语言:English (United States)
Sure, you can submit a form and maybe do a trick here and there with some crafty HTML and CSS coding, but you’re really just playing Weekend at Bernie’s propping up a lifeless web page. Real live ...
"Trick"这一主题似乎与一套特别的字体资源相关,其中包括多种不同风格的图像文件(.gif)和TrueType字体文件(.TTF)。让我们深入探讨一下这个话题。 首先,.gif 文件是一种常见的图像格式,支持透明度和动画,常...
Hattrick球场上座率概算 Hattrick球场上座率概算
### 重修 Slope Trick 技术解析 #### 一、引言 Slope Trick,作为一项优化动态规划(DP)问题的技术手段,在算法竞赛领域里占有重要地位。该技术的核心在于利用函数斜率的变化来简化计算过程,尤其是在面对那些代价...
ChromePastelFluoWebTheme(((和)))意味着我们从时尚到手写笔或其他任何方式,除非您是专业人士? 信息 这是深色网页的主题,chrome协议UI和URL前缀不能很好地完成(例如:chrome://),只有扩展页面配置部分...
4. **转换(Transforms)**:这个特性允许元素在二维或三维空间内进行旋转、缩放、平移和倾斜,无需JavaScript即可实现动态效果。使用`transform`属性,配合`rotate()`, `scale()`, `translate()`和`skew()`函数。 ...
【手掌(TRICK-ARM)血管成像扫描技术】 手掌(TRICK-ARM)血管成像扫描技术是一种基于磁共振成像(MRI)的血管造影技术,特别针对手掌区域的血管疾病进行诊断。这项技术在临床中具有显著的应用价值,尤其在识别手掌血管...