dom

Capturing onload event when dynamically loading .js files ?

Is there a capture the on load event when dynamically adding a script tag with JavaScript in IE? The code below works in FireFox and Chrome but not in IE. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" > <head r...

Is it possible to access a web page’s unparsed CSS text?

I want to parse the CSS files that are loaded with an HTML page but I don’t want to make AJAX calls to reload the CSS files that have already been loaded. Is there any way to access the pages unparsed CSS text? For example, it would allow one to access -moz-* declarations in Safari. ...

Is it true that first line of Javascript will be executed only after all script tags with src attribute are downloaded and evaluated?

By first line of Javascript I meant the JS code inside tags with no "src" attribute. ...

(Override || Extend) Javascript Method

Hi, I want to change the method DomElement.appendChild() to work differently when applied on an Object that I have created: // using MooTools; var domElement = new Class({...}); var MyObject = new domElement(...); $(document).appendChild(MyObject); // Error // I want to add to (extend) appendChild, to do something specific, when: al...

Sorting XML file

Hi, I need to sort an XML by tag names and attribute. Is it possible using DOM? I need the result in a sorted XML file not HTML. for example: <books> <book id='1'> <name value='N1'/> <author value='A1'/> </book> <book id='3'> <name value='N3'/> <author value='A3'/> </book> <book id='2'> <author value='A2'/> <name val...

Problem in using javascript childNodes.length property with elem.

Hi everyone, I have a treeview with drag and drop functionality. Upon completion of drag and drop I need to find the count of the child nodes of the new parent node. So for that I'm using the following lines var childnodelength=elem.parentNode.parentNode.childNodes.length; alert(childnodelength); But I always get the same value of ...

Edit existing browser window DOM

(Note: This question is for an internal-use-only project, so some of the usual security concerns don't apply.) I'm trying to find some way to insert HTML/Javascript into a pre-existing IE7 browser window. Basically, we are using a web-based support ticket system, and I am inserting code into the page to add links and lists and such, to ...

How do I parse partial HTML?

I'm trying to parse some HTML with DOM in PHP, but I'm having some problems. First, in case this change the solution, the HTML that I have is not a full page, rather, it's only part of it. <!-- This is the HTML that I have --><a href='/games/'> <div id='game'> <img src='http://images.example.com/games.gif' width='300' height='137' borde...

Select div using wildcard ID

How to select a div using it's ID but with a widcard? If the DIV's ID is statusMessage_1098, I would like to select it in some way like document.getElementById('statusMessage_*'). This is because until the page is generated, I don't know the suffix of the ID and only one such ID will be present in a page. Is this possible? Thanks for ...

how to capture all changes to the contents of a <body> element in JS

I am trying to write an extension for Google Chrome. I want to capture any keyboard input on a given page, and do something magic to it. I am able to do most of what I need with these lines: document.addEventListener("keydown", function(event) { OnKeyDown(event); }, false); document.addEventListener("keyup", function(event) { OnKeyDow...

Enable checkbox B only when checkbox A is enabled and the other way around.

I have a two columns of checkboxes with predictable names. How can I disable a checkbox in column B when the ones in column a is unchecked and only enable it when the first the checkbox a is enabled? <dmf:checkbox name="someNameAColumnNumber" value="true" onclick = "enableColumnBCheckBox" runatclient="true" /> Is there somethi...

Full window onClick handler in Firefox and Internet Explorer

I would like an event handler to fire whenever someone clicks anywhere on a window (so I can clear away a menu if they click someplace other than the menu). The following works in Safari: function checkwho(ev) { obj=(window.external) ? event.srcElement : ev.target; var type=obj.nodeName; if ((type == 'BODY') || (typ...

DOM to use with SpiderMonkey?

I'm trying to use the GoogleMaps javascript library from inside of SpiderMonkey using the pythong wrapper, but I can't because of the lack of a DOM. Is there some way I can integrate a DOM into this so that I can get this to work? ...

How to remove an individual text node in a div without removing all of them?

How do I go about removing an individual dynamically created text node? I am generating input's on the fly and am using .createTextNode to place descriptive text before the elements. I need the ability to delete specific elements that are being created and am using .removeChild to do it. That works fine for removing an individual inp...

live for jquery elastic plugin?

i use jquery elastic plugin for expanding a textbox. it works great but i want to use this on a textbox that is added to the DOM with ajax but unfortunately this plugin has no live built-in function. is there a way to solve this? http://www.unwrongest.com/projects/elastic/ ...

How might I replace a portion of a link's href attribute with a variable value?

I have the following code, written using jQuery: var strval = '22' $("#quicknote").attr("href", "javascript:location.href=/'http://site.com/notes/add?projects=/'+ strval") Which results in the following attribute: <a href="javascript:location.href='http://site.com/notes/add?projects='+'strval'" id="quicknote"> But, what I wan...

jQuery: select an element's class and id at the same time?

I've got some links that I want to select class and id at the same time. This is because I've got 2 different behaviours. When a class of links got one class name they behave in one way, when the same clas of links got another class name they behave differently. The class names are switch with jquery. So I have to be able to select a l...

Tools for optimizing CSS rules by rewriting DOM paths/selectors

Do you know any tool that takes a CSS stylesheet and a bunch of HTML files and then is able to identify CSS rules on the DOM and rewrite them according to the optimal element DOM path? Example HTML snippet: <div id="container"> <div class="profile"> <img class="thumb" src="xxx" /> <span class="nickname">knoopx</span> </div> </div...

Seting User Agent param in PHP Simple HTML DOM Parser

Is there any way to include the user agent string along with the request send by PHP Simple HTML DOM Parser? ...

JS: How to make document.getElementById cross-browser?

Hi, document.getElementById doesn't seem to work across all browsers (I mean some old ones) and I am sure there are developers who are not aware of this. What solutions would you suggest to make it cross-browser? Thanks ...