dom

pros and cons for these 2 kinds of loading javascript files?

A: <script type="text/javascript" src="b1.js"></script> <script type="text/javascript" src="b2.js"></script> <script type="text/javascript" src="b3.js"></script> <script type="text/javascript" src="b4.js"></script> B: put all stuff in b1~b4 into another file t.js <script type="text/javascript" src="t.js"></script> Suppose b1~b4 eac...

what are different in these 2 executing flavors?

1. <div id="test"></div> <script type="text/javascript"> //operate document.getElementById('test') </script> 2. <div id="test"></div> <script type="text/javascript"> window.onload = function() { //operate document.getElementById('test') }; </script> Can we ensure that document.getElementById('test') exists just by putting javascr...

How can I know if an DOM element is currently on screen using jQuery.

Is there a function, or plugin, that tells me if more than 50% of a <div> block is currently being displayed? I know there are things like $.offset() but I didn't want to do it by hand every time the user resizes it's window or scroll to a region. Something on the lines of :visible, but that is currently visible. Thanks! ...

jquery drag image

i want to make a draggable image in jquery. first of all my experience with jquery is 0. having said that let me describe what i want to achieve. i have fixed width/height div. and the image contained inside the div is large in size. so i want the image to be draggable inside that div so that the user can see the entire image. can some...

javascript fade animations

i want a certain DOM element to fade into view in my script. i tried using the timeout feature but couldnt get it to work. hover.addEventListener('mouseover',function () {Core.addClass(cpanel,"on");},false); please tell me how to implement a fade-in effect for this. please dont recommend jquery or any other framework. ...

XML Output in Java -- what's with DOMImplementationLS ?

I just had to write the following stupid class to avoid going insane: import java.io.OutputStream; import org.w3c.dom.Document; import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSSerializer; public final class XMLSerializer { pu...

Excel XML Line Breaks within Cell from PHP DOM

I am trying to insert new lines into an Excel XML document. The entity that I need to insert is &#10; but whenever I insert that into PHP DOM, it just converts it to a normal line break. This is what I am getting: <Cell><Data>text text2 </Data></Cell> This is what I want: <Cell><Data>text&#10;text2&#10;</Data></Cell> I cannot figu...

JQuery selector

Given the following unordered list, the JQuery selector $("#root #2") selects: /ul/li/ul[@id='root']/li/ul[@id='1']/li/ul[@id='2'] Whereas I would have expected it to select the shorter path: /ul/li/ul[@id='root']/li/ul[@id='2'] Anyone any ideas? <ul> <li>root <ul id="root"> <li>1 <ul id="1"> <li>2 ...

Is there a way to tile a background image over a canvas path?

For example, I have a canvas in a page with some kind of a path. It is created by javascript this way: var context = $('#some_canvas').getContext('2d'); context.beginPath(); context.lineWidth = 5; context.strokeStyle = '#000000'; context.moveTo(0, 0); context.lineTo(100, 100); context.stroke(); Is there a way to make the path that app...

What is the best way to inject HTML into the DOM with jQuery?

Hi, I'm working on a calendar page that allows a user to click on a day, and enter an entry for that day with a form that pops up. I'm no stranger to DOM manipulation with jQuery, but this is something I've done before and I'm beginning to wonder if there's a more efficient way to do this? Would building the HTML manually within JavaS...

Simple jQuery ajax example not finding elements in returned HTML

I'm trying to learn jQurey's ajax functions. I've got it working, but jQuery doesn't find elements in the returned HTML DOM. In the same folder as jquery, run this page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xm...

Iterate all XML node generations in java DOM

I want to check to see if an XML document contains a 'person' element anywhere inside. I can check all the first-generation elements very simply: NodeList nodeList = root.getChildNodes(); for(int i=0; i<nodeList.getLength(); i++){ Node childNode = nodeList.item(i); if (childNode.getNodeName() == "person") { //do something with ...

Is it possible to use jQuery to read meta tags

Is it possible to use jQuery to read meta tags. If so do you know what the basic structure of the code will be, or have links to any tutorials. ...

Which behavior to expect from jQuery find()?

Here's a Firebug session >>> var e = $("<div>div-1<p>p-1</p></div><div>div-2</div><p>p-2</p>"); >>> e [div, div, p] >>> e.find('div') [] >>> e.find('p') [p] Isn't e.find('div') and e.find('p') supposed to return [div, div] and [p, p] respectively? ...

Writing a non-GUI bot using Mozilla Framework

Hi, I'm looking for a way to write a non-GUI bot using Mozilla Framework. The bot should be able to work like normal browser (automatically download relevant JS files, make XMLHTTPRequests, run JS operations, modify DOM), except no GUI will be needed. I wonder if it is possbile to build XULRunner without X, GTK/KDE (without any GUI dep...

removing html element styles via javascript

Hello all, I'm trying to replace an element's inline style tag value. The current element looks like this: `<tr class="row-even" style="background: red none repeat scroll 0% 0%; position: relative; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" id="0000ph2009-0...

PHP returning page error on simplexml print_r

The problem is only happening with one file when I try to do a DocumentDOM/SimpleXML method, so it seems like the issue is with that file. No clue what it could be. If I do the following: $file = "test1.html"; $dom = DOMDocument::loadHTMLFile($file); $xml = simplexml_import_dom($dom); print_r($xml); in Chrome, I get a "Page Unavaila...

Why are arrow keys, tab, etc not received by input field's onkeypress handler in some browsers?

I'm building a text input field specialized for entering and editing times. One of the parts of the functionality calls for various ways to focus on the different components of the time (hours, minutes, seconds), which I indicate through a text selection. Direct selection is possible with the mouse and this is working great. The other fe...

Access javascript DOM objects in PHP

Hello, I have a javascript code helping me to dynamically create row after row in a table and to delete a row from that table. each row has four cells. cell 1 for instance contains a text zone. to differentiate cell1 from row 1 with cell1 from row 2, I rename my cell 1 like that cell1.name= cell1.name + '_' + row.rowIndex. I create a s...

Javascript and DOM event interaction and possible race conditions

Scenario: Preloading images Perform an ajax query Show loading screen Retrieve results from ajax query Insert images into the dom Wait for images to finish loading Hide loading screen I was thinking of doing the following: function ajaxCallback(results) { /* snip insert into dom code */ $(".waitForLoad").each(function() { ...