dom

Loading and removing images with DOM, Javascript

I'm new to DOM and I'm having trouble removing multiple images that I loaded this loads 7 images (1.jpg, 2.jpg, etc..) function loadImages() { for (var i = 1; i < 8; i++ ) { var img = document.createElement("img"); img.src = "images/"+i+".jpg"; var idName = "img"+i+""; document.getElementById(idNa...

window.onload seems to trigger before the DOM is loaded (JavaScript)

I am having trouble with the window.onload and document.onload events. Everything I read tells me these will not trigger until the DOM is fully loaded with all its resources, it seems like this isn't happening for me: I tried the following simple page in Chrome 4.1.249.1036 (41514) and IE 8.0.7600.16385 with the same result: both displa...

Should a "script" tag be allowed to remove itself?

We've been having a discussion at our workplace on this with some for and some against the behavior. Wanted to hear views from you guys : <html> <body> <div> Test! <script> document.body.removeChild(document.getElementsByTagName('div')[0]); </script> </div> </body> </html> Should the above script work and do what it's supposed to do?...

How to overwrite html element from javascript?

I have HTML page with some HTML element with ID="logo". I need to create JS script (with no external libs calls) that will overwrite that html element with other HTML element like "<div id=logo> stuff inside </div>". ...

Java+DOM: Registering and using modification listeners: tutorials?

Hello, everyone! Please point me to some tutorials or other explaining examples about how to register and use modification listeners with Java's DOM implementation. On the web I find only Javascript or Flex examples. My target is to get to know when a Node was modified. I tried out several approaches, nothing works. Could it be that ...

DOM - More than 5 'window' objects on one page

Hi, I'm trying to extract data from one of my websites using Greasemonkey. Problem is, the script runs 6 times because apparently the page loads content from 6 different servers. So if I put in an alert ("Hey"); the code runs 6 times and I get 6 alerts. How can I wait for the entire page to load and then start playing with the DOM. A...

Parse Nested XML tags with the same name

Let's take a simple XML document: <x> <e> <e> <e>Whatever 1</e> </e> </e> <e> <e> <e>Whatever 2</e> </e> </e> <e> <e> <e>Whatever 3</e> </e> </e> </x> Using the standard org.w3c.dom, I can get the nodes in X by doing.. Nod...

searching XML documents using php

I am trying to make a search function using the combination of DOM, PHP and XML. I got something up and running but the problem is that my search function will only accept exact terms, on top of this am wondering if the method I picked the most efficient $searchTerm = "Lupe"; $doc = new DOMDocument(); foreach (file('musicInformation.xml...

Select list value undefined in $(document).ready

I have the following code, which I want to load values on a selection change, and also do the selection load initially (since FF 'saves' the last value of the drop down under certain circumstances). The select part of the function works correctly, but for some reason when calling load2 directly the value of $('#select1').value is unde...

Traversing/Manipulating new window from parent window with jquery

I found a question already with a possible solution, but I had already tried the method suggested before reading it, and it even says it's inconsistent. So I guess I'm wondering why this doesn't work: $("img").click(function() { var imgwindow = window.open('imgwin.html','','width=460,height=345'); alert(imgwindow.find("img").att...

XML creation using DOM and MYSQL

I am trying to create a XML document from information extracted from a mysql table. I am using a tutorial to accomplish this http://www.tonymarston.net/php-mysql/dom.html#a5 what I want to do is to create each element separately, instead of creating them all at once as shown in the tutorial. In order to do that I am trying to place th...

JavaScript and XML Dom - Nested Loop

So I'm a beginner in XML DOM and JavaScript but I've run into an issue. I'm using the script to display my XML data in a table on an existing site. The problem comes in nesting a loop in my JavaScript code. Here is my XML: <?xml version="1.0" encoding="utf-8"?> <book_list> <author> <first_name>Mary</first_name> <last_name>Abb...

How do I extend in my class a Dom element, in mootools

I want to create a Class, say MyDiv, which inherits from the original DOM DIV element. Later in my code I would like to use it like that: $('a-container').adopt(new MyDiv('my own set of params')); I am missing the exact syntax to do it. ...

loading XML string into Xslt sheet

I am trying to load a xml document I created using PHP and DOM into a xslt sheet, but having no luck. $xml_string = $doc->saveXML(); //echo $xml_string; $xml = new DOMDocument; $xml->load($xml_string); $xsl = new DOMDocument; $xsl->load('musicInformation.xslt'); // Configure the transformer $proc = new XSLTProcessor; $proc->importS...

Detect an element that scrolls into viewport from below the fold?

I've found some ideas, such as http://www.dustindiaz.com/element-scroll-into-view/, but I need a Mozilla/Chrome compatible solution that's not using any frameworks (YUI, jQuery, Prototype, etc.) In short I need to convert this YUI code to non-YUI code: var Event = YAHOO.util.Event; var Dom = YAHOO.util.Dom; Event.on(window, 'load', fun...

jQuery to get innerHTML not working on a HTMLFontElement object...

I have jQuery to select all font elements that are children of the element with id="right" within the html stored in the var html... when I do an alert to see how many elements it gets: alert($("#right > font", html).length); it gives me an alert of: 5 but when I try any of the following, I don't get any alerts... alert($("#right > ...

On site load, how do you wrap all images in a link dynamically using Javascript?

I have barely any experience working with DOM and using Javascript, and I have a very specific task that I'm trying to accomplish. Let's say I have an image in my HTML: <img src="foo.jpg" /> When the site loads, I want to take that image (all images in the document, actually), and wrap them in a link: <a href="http://www.foobar.com...

how to change link url on the web browser's status bar.

I already read many article about this issue in here, SO. I just want to discuss how to do it. NOT the moral issue. -- for example. at the google search webpage. before I click the link, the link does not indicate the google url. but After I click the link with shift-key, the url on the status bar is changed. this mean the goo...

Firefox DOMContentLoaded event problem

Hi, i've created a script that works with the Dom so it has to wait until the Dom is ready before execute every operation. I want that this script can be included in two ways: In the head tag so that it is loaded before the Dom is ready. I've used document.addEventListener("DOMContentLoaded",function(){...},false) for this and it works...

How to retrieve multiple anchors URLs with jQuery ?

Hello, I would like to create a javascript playlist with Jplayer. This is a nice and easy tool, however I never coded with javascript. Look at the javascript used in this demo. It uses a list to store MP3 and Ogg files : var myPlayList = [ {name:"Tempered Song",mp3:"http://www.miaowmusic.com/mp3/Miaow-01-Tempered-song.mp3",ogg:"ht...