- 浏览: 399693 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (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 newer version of Internet explorer, Opera and Firefox, I think the Chrome as well. has the prototype for HTML element.
so by which, the HTML element is represented by some base functions. so you can extend more function to it by add something to its prototype.
/************************************** *@Summary * Internet Explorer 8, Firefox, Safari, and Opera all provides base functions representing objects in the DOM. * * this utilize this feature to extend the element in the HTML * * @Usage: * // old way var a = document.getElementById("a"); a.parentNode.removeChild(a); // New way document.getElementById("b").remove(); * @TODO: * test it ***************************************/ HTMLElement.prototype.remove = function () { if (this.parentNode) { this.parentNode.removeChild(this); } };
Below show something that you can do about the HTMElement.
发表评论
-
javascript - trick to cross browser DOM ready event
2012-08-24 08:23 927the "ready" event ... -
javascript - trick to simulate mouseenter and mouseleave
2012-08-23 08:31 2254Previously we discussed javasc ... -
javascript - trick to simulate the change event
2012-08-22 08:51 1659In the previous discussion a ... -
javascript - trick to simulate bubbling submit event
2012-08-22 08:03 906In the previous discussion abou ... -
javascript - trick to implement bubbling submit event
2012-08-23 07:55 700Following up to the javascrip ... -
javascript - trick to detect bubbling supportability
2012-08-20 22:22 971Event delegation is oe of the b ... -
javascript - trigger event and custom events
2012-08-20 21:58 2078In the previous post - javascri ... -
javascript - trick to handlers management
2012-08-20 08:19 1024We have discussed "javascr ... -
javascript - trick to centralized store
2012-08-20 07:52 818For a number of reasons it's ... -
javascript - trick to fix the event object
2012-08-20 07:47 880Many browsers, especially In ... -
javascript - tricks to deal with colors
2012-08-15 08:34 766There are a couple of ways to r ... -
javascript - trick to manipulate the opacity
2012-08-15 08:26 765All other browsre may have supp ... -
javascript - trick to test visibility of an element
2012-08-15 08:15 521though there is a visible prope ... -
javascript - trick to get and set height and width
2012-08-15 08:05 548when looking at properties t ... -
javascript - trick to set/get attributes that expects px values
2012-08-16 11:00 516When setting a number into a ... -
javascript - trick to get and set CSS style
2012-08-16 11:00 747while it will not be so much tr ... -
javascript - trick to normalize href for IE
2012-08-16 10:59 533IE is again the only browser th ... -
javascript - trick IE form and its expando attribute
2012-08-16 10:59 1041there is a known issue that if ... -
javascript expando and attributes
2012-08-14 08:15 1038expando is something like this ... -
javascript - trick to getText and setText
2012-08-14 07:40 1144it is not as simple as you thin ...
相关推荐
在JavaScript中,`HTMLElement`是DOM(文档对象模型)的一部分,表示HTML元素的接口。它提供了访问和修改HTML元素属性、样式以及事件处理的方法。在实际编程中,我们经常需要对`HTMLElement`对象进行一系列的操作,...
- 当试图使用`Object.prototype.xxx`这样的通用方法时,可能不适用于HTMLElement对象,因为它们可能没有这些方法。需查阅文档确认哪些方法适用于特定的DOM对象。 通过以上方法,你可以有效地对HTMLElement对象进行...
针对这一问题,作者将分享一种方法,即利用HTMLElement的Prototype来定义一个新的方法bind,这类似于现在流行的库如jQuery的事件绑定方法。 首先,我们需要了解DOM的结构,它是以树状形式存在于文档中的,每个节点...
在JavaScript领域中,Prototype框架是一个强大的库,它简化了许多复杂的DOM操作,使得开发者能够更轻松地处理事件、动态创建元素等。本篇文章将深入探讨Prototype对象的核心概念与具体实现细节,帮助读者更好地理解...
代码中首先检查当前环境是否支持`HTMLElement.prototype`,然后定义了`outerHTML`的setter和getter,实现了在Firefox中对元素及其子元素进行替换和获取的功能。 ### 二、数组访问方式的统一 在IE中,可以使用点号...
prototype: Object.create(HTMLElement.prototype), createdCallback: function() { // 元素创建时执行的代码 }, attachedCallback: function() { // 元素插入文档时执行的代码 }, detachedCallback: ...
HTMLElement.prototype.__defineGetter__("runtimeStyle", element_prototype_get_runtimeStyle); window.constructor.prototype.__defineGetter__("event", window_prototype_get_event); } ``` 这里,`...
在提供的代码中,开发者通过检测浏览器类型(通过`navigator.userAgent`)来判断是否为Firefox,然后使用JavaScript的原型链(prototype)来添加`innerText`的getter和setter方法。这是通过`__defineGetter__`和`__...
HTMLElement.prototype.click = function() { if (typeof this.onclick == 'function') { if (this.onclick({type: 'click'}) && this.href) { window.open(this.href, this.target ? this.target : '_self'); ...
兼容firefox的 outerHTML,FF中没有outerHtml的方法 代码如下: if (window.HTMLElement) { HTMLElement.prototype.__defineSetter__(“outerHTML”,function(sHTML) { var r=this.ownerDocument.createRange();...
2. **宿主对象**:由运行JavaScript的环境(如浏览器)提供,如HTMLElement,它们与特定的执行环境紧密相关。 3. **自定义对象**:程序员通过代码创建的对象,可以根据需求定义属性和方法。 对象的属性有两种类型:...
代码如下: if (window.HTMLElement) { HTMLElement.prototype.__defineSetter__(“outerHTML”,function(sHTML) { var r=this.ownerDocument.createRange(); r.setStartBefore(this); var df=r....
通过Object.prototype.__defineGetter__和Object.prototype.__defineSetter__方法,可以为HTMLElement类动态添加innerText的getter和setter。innerText方法允许开发者获取或设置HTML元素内的文本内容,与textContent...
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; ``` 或者通过正则匹配: ```javascript var isSafari = /Safari/.test(navigator.userAgent) && !/Chrome/....
自定义元素样式 创建自定义元素后,自动将样式注入到它的 Shadow DOM ... create ( HTMLElement . prototype )}styles ( CustomElement , ` h1 { color: red; text-transform: uppercase; }` )CustomElement . prototyp
(但未使用任何JavaScript代码) 演示版 在此处查看演示: : 安装 您可以将dist/x-json.html文件复制到服务器上的某个位置,也可以使用bower: bower install --save x-json 用法 < script > if ( '...
HTMLElement.prototype.__defineGetter__("innerText", function() { var anyString = ""; var childS = this.childNodes; for (var i = 0; i ; i++) { if (childS[i].nodeType == 1) { anyString += childS[i...
HTMLElement.prototype.__defineGetter__("innerText", function() { var anyString = ""; var childS = this.childNodes; for (var i = 0; i ; i++) { if (childS[i].nodeType == 1) anyString += childS[i]....
* @param {HTMLElement} element - 需要操作的DOM元素 * @param {number} [value] - 设置的透明度值,范围0-1 * @returns {number | void} - 若只传入element则返回透明度值;若传入element和value则不返回值 */...