Welcome To Snipplr


Everyone's Recent Snippets Tagged DOM



1 362 posted 11 years ago by freelancephp
A simple, non-recursive function that I use to return the first element with an ID that contains a certain ID string. Sometimes, APS.NET appends the Naming Container ID to the IDs of controls, and in instances where the ClientID of a control you wa...
0 224 posted 11 years ago by erintechspired
Gets the outerHTML of a DOMElement. For a more optimal version check the URL.
0 357 posted 11 years ago by Znupi
This example uses file_get_contents to retrieve remote HTML. From there, we can parse through it using PHP5's DOMDocument and DOMXpath. XPath Queries are easy to create using the Firefox extension "XPather"
3 781 posted 11 years ago by adamcoulombe
pretty basic; dimensions of screen and browser display window
0 292 posted 12 years ago by rwczippy
Go to page, then place code in address bar and generated code will be shown in new window.
1 306 posted 12 years ago by bionic
I just noticed in Firefox 3.5.2 that setting `disabled = true` for a focused text input seems to make it impossible to re-focus after setting `disabled = false`. The solution is to blur it before disabling.
0 419 posted 12 years ago by cyberhobo
Usage: //any element window.onload = function(){ focusFirstInput(); } or // form elements under 'content-body' window.onload = function(){ focusFirstInput('content-body'); }
0 310 posted 12 years ago by neoprolog
If you want to trigger an event on an matched element and that element may be introduced into the DOM from an Ajax request, you can still match against it by using the livequery plugin and the following code.
1 265 posted 12 years ago by Meander365
Manipulates XML nodes using PHP's Dom library. Includes XPath navigation, child manipulation, and deletion of current document.
0 300 posted 12 years ago by mikeevans
Memory leakage in IE6/7 if the event handlers are not purged before deleting an element.
0 305 posted 12 years ago by iTony
<a href="javascript:(function(){var%20ids=[];jQuery('*').each(function(){if(this.id&&this.id!==''){if(ids[this.id]){console.log('duplicate%20id%20found:%20'+this.id,this,ids[this.id])}else{ids[this.id]=this}}});})();">Find duplicate IDs</a> (drag me...
1 381 posted 12 years ago by krunkosaurus
Append html to a div tag (using System.Web.UI.HtmlControls)
1 487 posted 12 years ago by hobeau
Example: Add the following ccs '@media print { body { font-size: 12pt } }' to the document.
0 447 posted 12 years ago by HubertGaulin
fix for IE, adds getComputedStyle method for the object window and getPropertyValue method for the object, which returns getComputedStyle
1 1563 posted 12 years ago by Jman
Great little snippit to add a <tr> to the bottom of a table. Note the use of the context in the jQuery e.g var n = $('tr:last td', this).length; Will have to use this in the future, very good to know!
4 694 posted 12 years ago by 1man
A little bit of browser detection and some functions to get the viewport height and width, crossbrowser.
1 602 posted 12 years ago by ShiftyP
The basis to a spider.
5 389 posted 12 years ago by Unreal
It is utterly annoying when DOM event handler exceptions fail silently with Firebug. This package fixes this common problem.
0 313 posted 12 years ago by miohtama
This function will sort an array of DOM elements in order of the DOM position. Useful when using calls such as $$("img.L,img.M") which doesn;t return a sorted element array. It uses prototype but you can replace the Prototype.Browser stuff with a...
0 434 posted 13 years ago by kouphax
Borrowed from Ajaxian, url is above.
0 306 posted 13 years ago by mikegreen
Use sample: var inputTxt = getElementsByAttr('input', 'type', 'text');
1 272 posted 13 years ago by kcmr
Determines if a given element is visible, by checking a variety of things. Will work for CSS or inline style declarations of visible:hidden or display: none. Will check if it's inside of an invisible element, as well.
3 393 posted 13 years ago by TALlama
This is a little trick I came up with to add outerHTML functionality in Firefox. For those who aren't familiar with outerHTML, it is an IE addition to the DOM that will return the element's HTML PLUS it's innerHTML. Is it really needed? No, but it ca...
1 581 posted 13 years ago by localhorst