dom

How to list all registered events of a DOM node using Javascript?

I can add or remove an event handler for a DOM node. Is it possible to find out all the registered events handlers of a given DOM node? I am referring to straight Javascript meaning no frameworks or toolkits like jquery, dojo, Prototype, GWT, etc. If the answer is no, any reason why? Security issues? ...

Why does removeChild() prevent me from doing appendChild() within a Javascript Function?

In this code when I call the cleanGrid() function my goal was to get rid of the div that was class 'circle' and to replace it with a div with class 'square'. For what I'm really using this code for they are not replacable items so replaceChild() would not work. If I comment out the function call to cleanGrid() the code runs fine and the ...

createDocumentFragment and jQuery

Hi, i have a big table and need to set CSS-classes on it etc. So i clone the table into a documentFragment to prevent the browsers reflow for each touched DOM-property etc. The Problem is, i set much of $.data and have $.live events appended to the tables TD's. So the question is, how can i preserve the $.data of the table for the new t...

Removing an element from DOM

I use this method to escape strings of HTML code on client side: function escapeHTML(str) { var div = document.createElement('div'); var text = document.createTextNode(str); div.appendChild(text); return div.innerHTML; }; I am a bit concerned about memory leaks because I'm creating DOM element and not destroying it. The p...

How can I get an object's absolute position on the page in Javascript?

I want to get an object's absolute x,y position on the page in Javascript. How can I do this? I tried obj.offsetTop and obj.offsetLeft, but those only give the position relative to the parent element. I guess I could loop through and add the parent's offset, and its parent's offset, and so on until I get to the object with no parent, ...

c# webbrowser control displaying "special folder" contents : why are Document and DocumentDom always null ?

Hi, In a C# WinForms, .NET Framework 3.5, project with a WebBrower control on the form : ... with a project reference set to MSHTMLdll and the WinForm code : "using mshtml;" ... you can load a "special folder," like the Favorites folder, into the browser easily. after you've loaded a "special folder" : what appears in the WebBrowser ...

Using non persistent Http Cookies to deliver out of band data to the browser

Imagine that your web application maintains a hit counter for one or multiple pages and that it also aggressively caches those pages for anonymous visitors. This poses the problem that at least the hitcount would be out of date for those visitors because although the hitcounter is accurately maintained on the server even for those visito...

Waiting x milliseconds after an event, recheck and trigger

I currently have a jQuery.event listener, which once triggers will display an otherwise hidden element (a rollover, basically). However, is there a way I can get jQuery to wait a few milliseconds, recheck to ensure the mouse is still over the element and then trigger the .show() event if it is? I currently have: $("#who-mousearea").mo...

Javascript: How to get all elements that are highlighted

I want to get all of the elements in a user highlighted area. The problem is that I don't know how to traverse to different parts of the DOM, when the elements are on a different part of the tree. My code so far can only get the elements off the startContainer of the selection range. Do I need some sort of recursion? Here is my code:...

Jquery selector problem

I have two in a table with ids row_26 and notificationrow_26. notificationrow_26 is dynamically added to DOM after page has been loaded. I want to highlight notificationrow_26. So I use var deviceUID = 26; $("#notificationrow_" + deviceUID).effect("highlight", {}, 3000); but when I do this. It does not highlight that row. I also tri...

i need the full dom node path of element

i need to search the html document for <p class="content"> text here </p> and then output the full node path (CSS or XPATH) for isntance html > body > div class ="something" > table > tr > p class="content" i tried with nokogiri but it doesn't handle the class and other attributes well.. i need a parser that does this without probl...

Can I use jQuery to easily shift li elements up or down?

I have a menu like this: <ul id="menu" class="undecorated"> <li id="menuHome"><a href="/">Home</a> </li> <li id="menuAbout"><a href="/Usergroup/About">About</a> </li> <li id="menuArchives"><a href="/Usergroup/Archives">Archives</a> </li> <li id="menuLinks"><a href="/Usergroup/Links">Links</a> </li...

Extract all links from a string.

I have a javascript variable containing the HTML source code of a page (not the source of the current page), I need to extract all links from this variable. Any clues as to what's the best way of doing this? Is it possible to create a DOM for the HTML in the variable and then walk that? ...

How to inherit from the DOM element class

I want to write some javascript classes which extend DOM nodes (so that I can then insert instances of my class directly into the DOM), but am having difficulty finding out which class/prototype I should inherit from. eg function myExtendedElement() { this.superclass = ClassA; this.superclass(); delete this.supercl...

Easy JQuery question: populate a select box with an object rather than html text?

In ASP C#, you can create a select (ListBox) then populate it with items (ListItem): ListBox1.Items.Add( new ListItem("Display name", "value")); This has an Add method that takes a ListItem option object. Is there something similar in JQuery where you can add JavaScript objects to JQuery selected DOM objects without using ad hoc html t...

Java+DOM: How do I set the base namespace of an (already created) Document?

Hello! I am dealing with an already created Document object. I have to be able to set it's base namespace (attribute name "xmlns") to certain value. My input is DOM and is something like: <root>...some content...</root> What I need is DOM which is something like: <root xmlns="myNamespace">...some content...</root> That's it. Easy,...

Programmatically creating an XML Document using an XSD

Hi I need to create XML documents using built-in java org.w3c.dom or jdom packages conforming to a set of XSD files. The XSD files are similar but not the same. In essence, I need to create the XML file as per the XSD given to me dynamically. What is the best way to do it. I have checked the Validator package, it does not have any fea...

Mozilla Parser for screen scraping

I'm writing an app that takes in HTML code of a page and extracts certain elements (such as tables) of the page and returns the html code for those elements. I'm attempting to do this in java using the Mozilla parser to simplify the navigation through the page, but I'm having trouble extracting the html code needed. Maybe my whole appr...

Clear form button in HTML...do we really need this?

I usually add the clear form button to HTML forms by default, but tonight I had what alcholics call a "moment of clarity". Why the hell do we add this? In all my years of using the internet I have never gotten to the end of the form and thought "crap!, I screwed up, I need to reset this!". Is this button actually necessary or a hold ov...

Objective-C DOM XML parser for iPhone

Hello guys I'm looking for a way on the iPhone to parse an XML document using DOM. I have been using SAX with NSXMLParser but now I really want a DOM tree (or anything that can quickly translate the XML document into an NSDictionary) Thanks for any help ...