dom

passing value to eventListener functions

for ( var i=0; i<thumbs.length; i++) { var num = i; Core.addEventListener(thumbs[i], "click", Slide.thumbClick); } in the above code, i want to pass the value of var num to the thumbClick eventlistener. but i am unable to. if i try to display that value, it gives an undefined value. pls help ...

Is there a way to detect a DOM-node change in Javascript?

I am looking for a way to detect if anything changes within a given DOM node. Is there an event or other technique that would do this? Thanks! ...

Reliable cross browser way of setting Status bar text

I've heard of window.status and that it can be used to control the browser's status bar text, but I would like to know if there are better or newer methods that can do the same, with most modern browsers. Also, is it possible to change the status text multiple times after the page has loaded? ...

insertRow vs. appendChild

Which method is preferred for adding a row to a table? var tr = tbl.insertRow(-1); or var tr = document.createElement('tr'); tbl.appendChild(tr); ? ...

creating a new, empty document with javascript

I'm working with some very unintuitive xml (all the tags are things like "TX", "H", "VC"). I'd like to make a copy of this data, but with all of the tags renamed to what they actually mean. Can I create a new, empty document to put my new, nicely named tags in to? I've tried this: doc = (new DOMParser()).parseFromString("", 'text/xm...

PHP DOM functions reading line number from input file

I have a program which reads an XML file using the DOM functions: $doc = new DOMDocument('1.0'); $doc->load("myFile.xml"); As I traverse the nodes in this document, is there a way to tell which line of the input file the node was defined on? For example: 1: <!-- myFile.xml --> 2: <foobar> 3: <foo>FOO</foo> 4: <bar>BAR</bar> ...

What is the unique identifier for a DOM element/node

I am traversing a HTML document using javascript DOM. I want make a list (an array actually) of all nodes/elements and thier values. On w3schools website i found a script for traversing DOM but how do i store each node value in an array. I can't seem to find the unique identifier for a node. Anyone has any pointers? I was thinking of xp...

Copy one xml document to another using DOM

Hi guys, this is my situation: I have two org.w3c.dom.Document created from two xml files. What I want to obtain is brand new Document containing all the data of the two xml Document. Do you have any idea on how to do this? Thanks! Rob ...

node explorer script?

I'd like to display a DOM node tree in a browser, with collapsable children. I'm looking for pretty much the same functionality as FireBug's "html" tab, only I want it within the browser window, and I want to be able to choose an arbitrary node as the root. Before I write it myself, I figured I'd check to make sure no one can point me to...

how does a function know where it is located in the DOM?

hi, I'm trying to write a javascript function that adds some DOM nodes to the document in the place it was called, like this: ... <div> <script type="text/javascript"> pushStuffToDOMHere(args); </script> </div> ... i try to do it 'cleanly', without using node id property of the div, or innerHTML string manipulation. for t...

How to get current position of an image in jQuery?

Hi, I've been developing a image manipulation script which has a background and user can upload one or more images onto that background. I want users to be able to drag and move around the BG and finally they can generate final image. However, I have no idea how to get the position of draggable image position on BG. I've been searching a...

Do I need to do string sanitation before adding to DOM?

In our team we came up with the idea that we have to do sanitizing of strings before added to the DOM. We expected at least that double quotes would be troublesome if used in setAttribute and < and > if added to the node content. The first tests showed something different. We are using innerHTML to set a nodes content. This escapes all ...

Wanted: Resource for documented Cross-Browser differences

Where can I get a list of browser differences in the implementation of DOM? ...

Is it possible to get document of iframe with iframe_id?

AFAIK,I can achieve this goal by window.frames['frame_name'] but if I only know frame_id,is it possible to get the content too? You can try it out here: http://maishudi.com/rte-light-read-only/index.html btw,is it possible to get location attribute through iframe_id? I tried long ago but failed. ...

How to parse HTML from JavaScript in Firefox?

What is the best way to parse (get a DOM tree of) a HTML result of XmlHttpRequest in Firefox? EDIT: I do not have the DOM tree, I want to acquire it. XmlHttpRequest's "responseXML" works only when the result is actual XML, so I have only responseText to work with. The innerHTML hack doesn't seem to work with a complete HTML document...

How to query an XML string via DOM in jQuery

Hi. I would like to take a string and treat it as XML. Then I will be able to query with DOM via the jQuery.find. Everything was working fine in Firefox, but I realized this is not working in IE. I am doing this: var t = "<div><outer><inner>abc</inner><inner>def</inner></outer></div>"; alert("[" + $(t).find("outer").html() + "]"); ...

thumbnail access through for loop.

i am creating a photo gallery and am currently stuck on recognizing which thumbnail links to which pic. im using an addEventListener function, kindly suggest the method to go about. ...

List of in-browser UI techniques?

I'd like to know what can be done in a browser UI (using a browser+CSS+javascript, not using Flash or Silverlight). For example, I think it's possible to: Drag and drop Arrange list items horizontally, and make them behave like menu items Make things on page visible or invisible, depending on where the mouse is hovering I admit this ...

Hook onto the adding of new DOM elements with jQuery (or plain JS)

To be clear: I am not asking how to put existing hooks onto new DOM elements. I know about the live() function and the old livequery plugin. I am asking something else. What I want to know is how to hook onto the very creation of new DOM elements. The reason I'm asking is I'm creating a third-party user JS script that doesn't have co...

Checking if there is any textNodes in body using jquery

Hi, I need to check in some fast way if there is any text nodes on page, excluding white space. Preferably, I'd like to see if there is a way to do this with jQuery, and to be cross-browser. Thanks ...