dom

How do I auto-scroll to a specific table row?

I have an html page with a header, a table containing 100 items and a footer. When there is a search, I highlight the row containing the data. However, if the highlighted row is row 75, the user has to scroll down to find it. How can I automatically scroll to that row? I did see scrollTO() but see it only takes axis points. Any ...

replacing images inplace

I have a array of static images that I am using for an animation. I have one frame image that I want to update the image of and I have seen a lot of tutorials on animating images with javascript just simply update the source of an image. frame.src = animation[2].src; etc When I look at the resource tracking in chrome, it doesnt look l...

window.location.href but where the address bar changes

For some reason, using window.location.href doesn't change the URL in the user's address bar. Is there any reason why I'm getting this behavior? CODE Earlier, I posted to code here. But I see that I'm in a frame. For anyone who happens to have the same issue, window.top.location.href = 'page.htm'; will do the trick. PS. Apologies f...

How to select unknown numbers in javascript?

So for example I have: array(2,1,3,4,5,6,7) and I already know (2,1,3) How should I get (4,5,6, 7) if I know that all numbers exists from 1 to 7 and the numbers what I already know So I want an array with the numbers what I don't know yet. Sorry if sounds stupid :| ...

How to use getElementsByTagName() to find all nested elements?

I have the following HTML: <html> <head><title>Title</title></head> <body> <div id='div2'> <a href='#'>1</a> <div id='div1'> <a href='#'>2</a> </div> </div> </body> </html> ... and the following Javascript code, which I'm running through Greasemonkey: var nodes = document.body.getElementsByTa...

Android DOM Parsing Help

I have used XML DOM parsing BUt not able to display the LIST. of attributes..Local,Music,walk, sports....etc How it will code in oncreate() method. pls help me regard this.. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // DownloadLINK(URL); // } // private void DownloadLI...

How to remove DOM elements without memory leaks?

My Javascript build a list of "LI" elements. When I update the list memory usage grows and never go down. I am wondering what should I do to remove DOM nodes without memory leak. I tested in sIEve and it shows that browser keeps all elements which I thought was deleted by $.remove() or $.empty jQuery commands. Help!!! ...

How to replace a node in DOM with a new one?

I have some DOM element which I retrieve with getElementById method. I need to replace this element with new html-element (i.e. I want to see correctly-rendered <h1>hello</h1> in the place where the old element were shown. How can I do that? (p.s. jquery is not allowed). ...

How to remove elements of a page in htmlunit

Normally in PHP, I would just parse the old document and write to the new document while ignoring the unwanted elements. ...

Can I change the ID of an HTML element using Javascript?

I have javascript variable obj which represents an element in the DOM and I wish to change its ID. I have attempted to do this by the following, which also illustrates that it does not work! obj.id = "newID"; alert(obj.id); // this gives me newID as required var element = document.getElementById("newID"); if (element != null) { alert...

How to get an DOM Element [x,y] coordinates relative to the scrollbox?

How to get an DOM Element [x,y] coordinates in javascript? Specifically, the coordinates of a button inside a scrollbox. I found this offsetLeft attribute: var elements = scroll.children; // with 12 children if (!elements.item(2)) { print("no element"); } else if (!elements.item(2).offsetLeft) { print("no attribute"); } else { ...

HTML/DOM: What is standards equivalent of scrollHeight?

For nearly a decade i've been using: document.body.scrollHeight to return the "ideal" height of the browser window. This worked fine when i was forcing Internet Explorer into quirks mode, by using a quirks-mode doctype: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> Now i want to opt into standards mode, except the...

jquery remove from dom based on variable

Have a script to add / remove options from a select field -- the "value" of the option I want to remove should be equal to the "class" of the link clicked. I've tried several different versions of this script and I cannot for the life of me figure out how to properly get the variable delText into the function to remove it. help pls! ...

JQuery - Get Value Using a Selector

I'm trying to select the first link on a page after the page has completely loaded and redirect the page to the link on the first page. I understand how to use a selector, but I'm stumped as to how I can pick up the first item after the page loads. I'm assuming once I have the value I could use window.location = "http://www.google.co...

Why were window.scrollY and window.scrollX introduced?

As far as I know, pageY/XOffset properties were already available since Netscape 4 era. And it seems scrollY/X were introduced circa Netscape 6. Alternative question: Is there a browser which implements scrollY/X but doesn't support pageY/XOffset? ...

refresh a javascript file after an event?

I am using a keynav plugin that allows me to navigate up and down though a list. This list is dynamically generated using ajax and mysql. the suggesstions appear when someone begins to search into an input box. if the user clicks off and the list closes and then begins a new search, when the list is generated the second time, the keybo...

getElementsByTagNameNS in (X)HTML documents.

Hi everybody, I have a question on Javascript and DOM; shouldn't the following code retrieve the three foo:bar elements in the body? The alert window displays zero. It doesn't work in any browser I have (not even Chrome Canary). Thank you for helping, have a nice weekend. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:...

Dom LoadHTML Problem in PHP

Hi. Maybe I am missing something... but the DOM Object is empty in this code: $input = file_get_contents('http://www.google.com/'); $doc = new DOMDocument(); @$doc->loadHTML($input); //supress errors on invalid html! var_dump($doc); die(); I really don't know what could be wrong with that code. I have verified that $input is actually ...

Java XML transformation interface

I need to transform a XML. Usually I would use Saxon and a XSLT 2.0 stylehsheet for this. The transformations I have to do involve side-effects and are stateful and manipulate the contens of nodes, so implementing a XPath function doesn't make that much sense. I decided to implement a transformer class for this purpose. I found javax.xm...

Is there any easy way to get DOM descendants like with the parents() method when using jQuery?

$('something').parents('selectors') lets me move several levels up the DOM at once, versus parent() which unsurprisingly returns the current element's immediate parent. Unfortunately (though logically), children() does not operate like parents() and instead only returns the element's immediate children, similar to how parent() works. I'm...