dom

What is my script src URL?

Is there a simple and reliable way to determine the URL of the currently-executing JavaScript file (inside a web page)? My only thought on this is to scan the DOM for all the script src attributes to find how the current file was referenced and then figure out the absolute URL by applying it to document.location. Anyone have other idea...

Getting content of a script file using Javascript

Hi guys I have the following script element in my web page: <script src="default.js" type="text/javascript"></script> Using JavaScript, I want to be able to retrieve the content of the script file. I know I could use a ajax request to get the data but then I am getting something from the server that I already have locally. So what ...

How do I get the markup of an element, including itself using jQuery?

I know I can wrap it's .html() in a tag, but the element itself has a dynamically set id, class, etc. How do I get jQuery to return the element's markup including itself? ...

Speeding up jQuery empty() or replaceWith() Functions When Dealing with Large DOM Elements

Let me start off by apologizing for not giving a code snippet. The project I'm working on is proprietary and I'm afraid I can't show exactly what I'm working on. However, I'll do my best to be descriptive. Here's a breakdown of what goes on in my application: User clicks a button Server retrieves a list of images in the form of a data...

How can I change an XML element value from JavaScript?

I have an XML DB and I have been able to parse the XML using DOM with JS. The thing I am unable to figure out is, how can I change a value in my XML db? I tried using: xmlDoc.getElementsByTagName("COMMENT")[0].childNodes[0].nodeValue="text"; But this does not changes the actual DB. When I refresh my page, it gives me the same old v...

empty div not getting recognised in javscript

i am creating an empty div in the javacript DOM. but when i call some function on it, for example, var hover = document.createElement("div"); hover.className = "hover"; overlay.appendChild(hover); hover.onClick = alert("hi"); the onClick function isnt working. instead it displays an alert as soon as it reaches the div creation pa...

Javascript better way to identify node of callback than XSLT generate-id() on another attribute.

The init() is able to use the parameter passed to it in this example: <body onload="init(this);"> testdOnChange() in this example uses a more complicated technique with XSLT generate-id(): <testd:test testd_id="TESTD_ID_id0x03cc1988" testd_on_load="testdOnChange(testdGetElementById('TESTD_ID_id0x03cc1988'));" /> Is t...

DOMNode to DOMElement in php

I want to convert a DOMNode object from a call to getElementsByTagName to a DOMElement in order to access methods like getElementsByTagName on the child element. In any other language, I would cast and it would be easy, but after some quick looking, PHP does not have object casting. So what I need to know is how to get a DOMElement objec...

Streaming XPath evaluation

Are there any production-ready libraries for streaming XPath expressions evaluation against provided xml-document? My investigations show that most of existing solutions load entire DOM-tree into memory before evaluating xpath expression. ...

insert delet update xml file

Hey, I asked the almost the same question before also, but i have not yet been able to figure out how to solve this issue of mine. I have been assigned a project, in which I get a .xml file, which has field like, <TITLE>, <AUTHOR>,<ABSTRACT>, <COMMENT> and the <COMMENT> tag comes empty in the .xml, rest all the fields are already fil...

How to get the xml content of a node as a string?

Using PHP's DOM functions, how do you convert a DOM Node's contents into a string? <foo> Blah blah <bar baz="1">bah</bar> blah blah </foo> Given foo as the current context node, how do you get 'Blah blah <bar baz="1">bah</bar> blah blah' as a string? Using $node->textContent or $node->nodeValue just returns the text nodes, not the...

Does HTML Hidden control have any events? Like onchange or something?

Can I attach any event handlers to HTML hidden? Basically want to run a function with a hiiden control value changes. Thanks All, ~ck in San Diego ...

adding label from javascript

hi , i am trying to add a label from javascript but im getting error what i did was: document.getElementById(option).innerHTML="<label onclick='updateInfo('edit','qualification',"+data_id+","+data+")>"+data+"</label>"; what am i doing wrong ? ...

traversing a table with javascript DOM

I know this is the simplest problem ever, but I can't seem to find the answer and I'm searching in the dark, so a little help is appreciated. I'm trying to get the text in the node where class='song_artist'. I have a reference to the parent node, but just can't get to the text I'm looking for. My html looks like this: <tr id='0000moe2...

Can I determine what the default state of a checkbox was at pageload (or what value reset() reset it to.)

When an html page is loaded, different input elements can be initialed as they are declared in the HTML. If the user changes some of the input values and then executes a reset() on the form, then the form is reset to it's initial loaded state. My question is, can I determine that "initial element state was" using javascript (ideally i...

How to stop all DOM events using javascript?

I am writing a DOM inspector, something like what firebug is doing but sure very simpler "just inspect elements". What i want to do is when the user click on an element it will make some functions i wrote, and in same time i don't want this element to do any other pre attached events. Means: If the user inspected anchor element, and t...

Pass mouse events through absolutely-positioned element

I'm attempting to capture mouse events on an element with another absolutely-positioned element on top of it. Right now, events on the absolutely-positioned element hit it and bubble up to its parent, but I want it to be "transparent" to these mouse events and forward them on to whatever is behind it. How should I implement this? Click ...

Delaying a jquery script until everything else has loaded

I have a jquery script which I need to run only once everything else on the page, including some other javascripts (over which I have no control) have finished doing their thing. I though perhaps there was an alternative to $(document).ready but I haven't been able to find it. ...

Variables with respect to DOM

This is surely a JS beginner question. My issue is I want to use the value of the variable type to access the relevant checkbox; however it is treating the variable as a string. I have tried it to two ways. function toggleGroup(type) { if (document.getElementById(type).checked == true){ alert("foo"); } } or function ...

Mapping computed CSS styles to specified ones?

Is there a way to map the computed style of a dom element (as retrieved by window.getComputedStyle) to a corresponding CSSStyleRule in document.styleSheets? My ultimate goal is to retrieve specified values for dom elements (rather than computed values or actual values). ...