dom

how to get lastSibling by javascript?

There is a native "nextSibling" attribute,but how to get "lastSibling"? ...

IE problem: keyboard interaction with checkbox

I have an HTML table, and each row has a checkbox for selecting or deselecting its row. Whenever a checkbox changes value, I need to add or remove highlighting to the row and also ensure that the page's submit button is only enabled when at least one row is selected and disabled otherwise. The checkbox event handler is defined by the f...

what's the easiest method to append a TR to a table by javasript?

if the table id is known,so the table can be specified by docoument.getElementById(table_id), how can I append a TR element to that table in the easiest way? the TR is like follows: <tr><td><span>something here..</span></td></tr> ...

Aliasing a DOM function (Document.Write) and scripts on other domains

I want to force external 3rd party scripts (on seperate domains) to use my own custom implementation of document.write when I load them on my domain. ie: document.write = function(args) { // My custom Function } This works fine for scripts on the same domain, but scripts on other domains use the browser default. Can I overrid...

JavaScript event handler to initiate after 3 seconds

I need to initiate the event handler after 3 seconds of being focused on an image. How should I go about it? Also, I need to trigger another event handler, when I am at a particular part of an image, say the approximate middle of the image. How do I do this? ...

XML characters in python xml.dom

I am working on producing an xml document from python. We are using the xml.dom package to create the xml document. We are having a problem where we want to produce the character &#x03c6; which is a φ. However, when we put that string in a text node and call toxml() on it we get &amp;#x03c6;. Our current solution is to use saxutils....

Least memory intensive DOM element

I want to render some 4000 odd DOM elements using Javascript. Do all DOM element consume the same memory within the browser? For e.g. between SPAN, DIV, A, etc. are they all the same memory wise? ...

Modular Javascript library with functionality similar to jQuery.

jQuery and similar libraries provide a number of useful APIs for DOM traversal and manipulation. Where your site as high number of repeat visitors, their use is easily justified as caching will offset any bandwidth cost to the end user. In other cases visitors to the site might always be unique and thus the bandwidth penalty for these l...

Using document.write for fixed html

I'm creating a webform that has combos containing 100 values or so. The values are the same. The form may have several records. So if there are 100 records there are 10,000 lines which seems pretty wrong from a "download" point of view. The thing is: I want to keep that combo dynamic to keep the id from the database. So I came up t...

Google Analytics executing in a dynamically created modal window

I am using JavaScript to create a modal window when a user either clicks a link or submits a form. The modal window holds either a form if they click a link or a thank you page when a user submits a sign up form. The modal window is populated using innerHTML. The issue I am having is that these modal windows have Google Analytic tags in...

Nokogiri: How can I add a child to a node at a specific position?

Hello all, I have a node which has two children: an XML text and an XML element. <h1 id="Installation-blahblah">Installation on server<a href="#Installation-blah" class="wiki-anchor">&para;</a> In this case the XML text is: Installation on server and the XML element: <a href="#Installation-blah" class="wiki-anchor">anchor;</...

How can I set the focus of a browser tab in IE?

Setfocus() only works on windows, not browser tabs. Any ideas? ...

Is there a quick way in javascript to determine if an ancestor node is positioned absolutely without walking up the entire tree?

I need to determine if an HTML element is nested inside an element that is positioned absolutely. (1)* e.g. I can do this: function hasAbsoluteAncestor(obj){ while(obj != null){ if(window.getComputedStyle(obj,null).position == 'absolute'){ return true; } else { obj = obj.offsetParent; } } return false; } /...

Trigger an event on a specific part of an image

I want to trigger an event handler when the user hovers on a particular part of the image, like the center of the image or the right side of the image (area would include, say, about a 100 pixels). I am not using any framework, so this is normal javascript that I am working with. I am not sure if using image maps would work. Can anyone h...

How do you handle HTML element IDs and Javascript references when adding line items using Javascript?

First off, I read all of the suggested questions that sounded halfway relevant and didn't find anything that addressed my issue. Second, if this is already addressed somewhere, I didn't search well enough for it. Finally, on to the problem. :D I have a page that has a 'line item' on it. A 'line item', for our purposes, is simply a b...

What's the best way to store multiple values for jQuery's $.data()?

If storing multiple (10+) values on a large number of divs, is it more optimal to store them all in a single object, or as separate values? Single Object: $("#div_id").data("data", {foo:1, bar:2}); Separate Values: $("#div_id") .data("foo", 1) .data("bar", 2); What are the trade-offs of each method? Some of these attributes wi...

Browser back button and dynamic elements

I have a page that uses jQuery to create a number of <input> DOM elements dynamically based on what user picks from a <select> box. Let's say the user picks 4 from the select box, my script dynamically shows 4 input boxes. The problem is when the user refreshes or goes back to this page (with the browser back button). The elements tha...

Using Javascript in an element with injected HTML in jQuery

Hi, I'm trying to reference some javascript files in a remotely loaded (injected) HTML file via jQuery's .load() function. The javascript files I'm attempting to utilize in the loaded HTML file are already included in the loaded HTML's parent HTML page. Initially, I thought that making references to these files in the loaded HTML woul...

How to retrieve XML DOM in IE ?

I have an HTML form and iframe like this: <form id="frmUpload" target="ifrTarget" action='http://....asmx/SampleMethod'&gt; <input name="title" /><br /> ... <input type="submit"/> </form> <iframe id="ifrTarget" name="ifrTarget"></iframe> Action attribute points to my ASP.NET web service. When the form is submitted, the IFRAME ge...

Copying one DOM XML node to another in javascript

Hey guys, I wrote a simple function to copy contents(including all child nodes) from one node to another of an XML DOM Object. Surprisingly in the function, the for loop is not iterating for n=1 for some reason i cant figure out, please help, i've been trying to debug this in all possible ways from 4 days. FUNCTION THATS NOT ITERATING...