dom

How can I turn a string of HTML into a DOM object in a Firefox extension?

I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object? It appears that the general solution is to create a hidden iframe and throw the contents of the string into that. There has been ...

Getting the text from a drop-down box

This gets the value of whatever is selected in my dropdown menu. document.getElementById('newSkill').value I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at W3Schools but that didn't have the answer, does anybody here know? For those not su...

Firefox plugin - sockets

I've always wanted a way to make a socket connection to a server and allow the server to manipulate the page DOM. For example, this could be used in a stock quotes page, so the server can push new quotes as they become available. I know this is a classic limitation (feature?) of HTTP's request/response protocol, but I think this coul...

How do I remove a child node in HTML using JavaScript?

Is there some function like: document.getElementById("FirstDiv").clear() ? ...

Inserting at the very end in FCKeditor

FCKeditor has InsertHtml API (JavaScript API document) that inserts HTML in the current cursor position. How do I insert at the very end of the document? Do I need to start browser sniffing with something like this if ( element.insertAdjacentHTML ) // IE element.insertAdjacentHTML( 'beforeBegin', html ) ; else ...

Which Java DOM Wrapper is the Best or Most Popular?

I've used jdom in the past, and have looked briefly at XOM and DOM4j. Each seems to provide essentially the same thing, as they each provide a simplified wrapper over the (very obtuse) standard W3C DOM APIs. I know that JDOM went through some effort to develop a JSR and standardization process at one point, but as far as I know that ef...

DOM manipulation in PHP

I am looking for good methods of manipulating HTML in PHP. For example, the problem I'm currently have is dealing with malformed html. I am getting input that looks something like this: <div>This is some <b>text As you noticed, the html is missing closing tags. I could use regex or a XML Parser to solve this problem. However, it is l...

PHP - Determine Parent Node Of DOMElement

I'm translating my C# code for YouTube video comments into PHP. In order to properly nest comment replies I need to re-arrange XML nodes. In PHP I'm using DOMDocument and DOMXPath which closely corresponds to C# XmlDocument. I've gotten pretty far in my translation but now I'm stuck on getting the parent node of a DOMElement. A DOMElemen...

How to Maintain Correct Javascript Event After Using cloneNode(true)

I have a form element that contains multiple lines of inputs. Think of each line as attributes of a new object that I want to create in my web application. And, I want to be able to create multiple new objects in one HTTP POST. I'm using Javascript's built-in cloneNode(true) method to clone each line. The problem is that each input-lin...

Should DOM splitText and normalise compose to give the identity?

I got embroiled in a discussion about DOM implementation quirks yesterday, with gave rise to an interesting question regarding Text.splitText and Element.normalise behaviours, and how they should behave. In DOM Level 1 Core, Text.splitText is defined as... Breaks this Text node into two Text nodes at the specified offset, keeping bo...

Firefox vs. IE: innerHTML handling

After hours of debugging, it appears to me that in FireFox, the innerHTML of a DOM reflects what is actually in the markup, but in IE, the innerHTML reflects what's in the markup PLUS any changes made by the user or dynamically (i.e. via Javascript). Has anyone else found this to be true? Any interesting work-arounds to ensure both beha...

Should I use window.onload or script block?

I have a javascript function that manipulates the DOM when it is called (adds CSS classes, etc). This is invoked when the user changes some values in a form. When the document is first loading, I want to invoke this function to prepare the initial state (which is simpler in this case than setting up the DOM from the server side to the ...

How do I serialize a DOM to XML text, using JavaScript, in a cross browser way?

I have an XML object (loaded using XMLHTTPRequest's responseXML). I have modified the object (using jQuery) and would like to store it as text in a string. There is apparently a simple way to do it in Firefox et al: var xmlString = new XMLSerializer().serializeToString( doc ); (from rosettacode ) But how does one do it in IE6 and o...

Does Microsoft ASP.NET Ajax Cause DOM Object Leaks?

We've been using "Drip" to try and identify why pages with UpdatePanels in them tend to use a lot of client-side memory. With a page with a regular postback, we are seeing 0 leaks detected by Drip. However, when we add an update panel to the mix, every single DOM object that is inside of the update panel appears to leak (according to D...

Looking for a simple JavaScript example that updates DOM.

The question says it all. :) ...

How do I get the current location of an iframe?

I have built a basic data entry application allowing users to browse external content in iframe and enter data quickly from the same page. One of the data variables is the URL. Ideally I would like to be able to load the iframes current url into a textbox with javascript. I realize now that this is not going to happen due to security iss...

Is there any way to repopulate an Html Select's Options without firing the Change event (using jQuery)?

I have multiple selects: <select id="one"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> <select id="two"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> What I want is to select "one" from the first select,...

Are there any tools out there to compare the structure of 2 web pages?

I receive HTML pages from our creative team, and then use those to build aspx pages. One challenge I frequently face is getting the HTML I spit out to match theirs exactly. I almost always end up screwing up the nesting of <div>s between my page and the master pages. Does anyone know of a tool that will help in this situation -- someth...

Binding custom functions to DOM events in prototype?

Jquery has a great language construct that looks like this: $(document).ready(function() { $("a").click(function() { alert("Hello world!"); }); }); As you might guess this, once the document has loaded, binds a custom function to the onClick event of all a tags. The question is, how can I achieve this same kind of beh...

How to show a spinner while loading an image via JavaScript

I'm currently working on a web application which has a page which displays a single chart (a .png image). On another part of this page there are a set of links which, when clicked, the entire page reloads and looks exactly the same as before except for the chart in the middle of the page. What I want to do is when a link is clicked on ...