dom

Why can't i use prototype DOM methods on uninserted nodes in ie?

The goal here is to manipulate some DOM nodes before they are inserted into the document, using prototypeJs methods. Test cases: <html> <head> <script type="text/javascript" src="prototype.js" ></script> </head> <body> <script type="text/javascript"> var elt = document.createElement("DIV"); elt.id="root"; elt.innerHTML="<div id...

How to increase speed of getElementById() function on IE or give other solutions ?

I have a project using Javascript parse json string and put data into div content. In this case, all of itemname variables is the same div's id. If variable i about 900, I run this code in Firefox 3 for <10ms, but it run on IE 7 for >9s, IE process this code slower 100 times than Firefox I don't know what happen with IE ? If I remove...

What is the most effective way to create a reference to this HTML element using plain JavaScript?

If I have the following HTML: <div id="container"> <iframe></iframe> </div> What is the most effective way (mainly in terms of performance) to create a reference to the <iframe> DOM element? I'm using something like the following: var element = document.getElementById('container').getElementsByTagName('iframe')[0]; IIRC, though, ...

Is there a way to trigger an event with jQuery (or the regular DOM API) without invoking any handlers

I want to trigger a form submit, but not have my usual handlers for that form's submit be called. I could just unregister any listeners, before calling, but that feels ugly (and specific to form submits since they're the only type of event that I can guarantee will be the last to occur). ...

Setting namespace and schema using java dom

I have a root element in my output xml document that has no attributes: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root> .. </root> I need it to look something like this: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="my.x...

You need to select at least one radio button / checkbox

What would be the JavaScript code to check if the user has selected at least one radio button, knowing that the radio buttons all have the same "name" attribute? Same question for checkboxes. I do not use any fancy javascript frameworks such as JQuery and others ... ...

unable to get selected value from list box in IE 8

Hi All, unable to get selected value from list box in IE 8 var myvalue= document.getElementById("fileName").value; alert(myvalue); ...

Storing the path of a file a user selects from the file input as a session variable to repopulate the field later

I am developing a script in PHP for uploading files to a MySQL database. There various things that need to selected in addition to the actual file that go into the database entry. The script needs to be designed so that it checks to make sure all of the proper selections have been made, and if they are not the script returns to the upl...

dom in PHP saves new content over the old File

Each time i do $country = $this->dom->saveXML(); // put string in country $this->dom->save('country.xml'); It delets the old country.xml and creates a new country.xml how can i append the old content of country.xml to the new content and save it again as country.xml ...

Help me understand objects in DOM

I have a question about DOM objects. What I have learned is that everything in a document are objects? <form name="myform" action="script.js"> <input type="text">type something</input> </form> If we look at the example, is form an object with properties name and action? But are name and action themselves also objects? i don't qu...

How to prime HTML for use with JS accordion effect?

I've got a website set up with well structured pages, eg. <h1> for the website name, <h2> for the page name and <h3> for the different sections on the page. Anyway, I was looking to set a bunch of the really long pages (an FAQ page for example) up with an "accordion" effect, with the <h3> elements being the toggle and the content direct...

Fx on Javascript: How to fade stuff, etc without frameworks?

Hi, I would like to learn how to do fade, and similar effects on Javascript. I often get answers, like why not use Jquery, mootools, etc ? Well, I want to learn how stuff works, then I wont mind using any of these frameworks. I'm currently learning about making changes on the DOM, so, I've read a lot of stuff on this theme. Also, I've ...

XML parsing with java dom parser converts xml declaration into elements

Here is the xml file that I need to process as part of my assignment. <?xml-stylesheet type="text/xsl" href="people.xsl"?> <People> <Person> `...` </Person> `...` </People> I am using the "javax.xml.parsers.DocumentBuilderFactory" to create a dom parser. After parsing, the resultant document does not have People at t...

Obtaining body background color via Javascript (jQuery) in Webkit & Opera

This code only seems to work in Firefox. Safari and Opera don't like it: alert($("<body>").css("background-color")); I've tried other methods too which are even less successful. alert(document.getElementsByTagName("body")[0].styles.backgroundColor); alert(document.body.styles.backgroundColor); I've tested these browsers on Mac - an...

How can I attach JavaScript events to table cells created at runtime?

I have a page with two links. On each, I've attached a JavaScript onmouseover event. I require a tooltip to be displayed when the mouse encounters a link, and require that it should not disappear until I point the mouse at the other link. The problem is that I create table at runtime, and I want to display tooltips for the table cells ...

How to wrap with HTML tags a cross-boundary DOM selection range?

Right now I'm capturing users' text selections through s = window.getSelection() and range = s.getRangeAt(0) (browser's impls aside). Whenever a selection within a <p> is made, I can easily call range.surroundContents(document.createElement("em")) to have the selected text wrapped with an <em> tag. In this example, however, <p>This is ...

XML DOM parsing br tag

Hi, I need to parse a xml string to obtain the xml DOM, the problem I'm facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I'm aware this can be overcome by using <br></br> instead of <br /> in the string, but is there a way this can be done without making the above change. please ...

How to get attributes value while parsing xml with XML::DOM parser in perl ?

How can I get actual attribute value instead of XML::DOM::NamedNodeMap=HASH(0xa3246d4) while using getAttribute function from XML::DOM parser Code my $parent = $doc->getElementsByTagName ("ParentTag")->item(0); my @parent = $childnodes->getChildNodes(); { foreach my $parent(@parent) { ...

PHP DOM - accessing newly added nodes

Hi! I use the following to get a html document into DOM: $dom = new domDocument('1.0', 'utf-8'); $dom->loadHTML($html) and then I add some new content to an element in the html: $element = $dom->getElementById('mybox'); $f = $dom->createDocumentFragment(); $f->appendXML('<div id="newbox">foo</div>'); $element->appendChild($f); But...

Document Object Model - Differences between browsers

What are the primary differences between DOM in different browsers(Mozilla FireFox, IE, Opera, other)? If You can, please, give me some examples. ...