dom

jquery doesn't see new elements

Hi, I am new to JQuery, so bear with me :). I have a simple problem: $(document).ready(function() { $("#instrument").change(function() { $("#tunings").html("<select id=\"TuningSelector>\"[..]</div>"); }); $("#TuningSelector").change(function() { DoSomethingWithTheValue(); }); }); Problem i...

Create link in an html table with javascript.

I am using the following code to add columns dynamically to a html table: var tblHeadObj = window.opener.document.getElementById("maintable").tHead; var j=0; while(j < fname.length) { if(tblHeadObj != null) { for(var h = 0; h < tblHeadObj.rows.length; h++) { var newTH = window.opener.document.createElement('th'); ...

Nokogiri: Select content between element A and B

What's the smartest way to have Nokogiri select all content between the start and the stop element (including start-/stop-element)? Check example code below to understand what I'm looking for: require 'rubygems' require 'nokogiri' value = Nokogiri::HTML.parse(<<-HTML_END) "<html> <body> <p id='para-1'>A</p> <div clas...

Alternative to getElementsByTagName

Since the getElementsByTagName() function is new (DOM-1?) I wanted another more reliable method to get a reference to an element based on its tag name/id. Edit- Without using a framework, since I need to cut down on size; so 10-20K for a framework is unacceptable. I just need the JS code that can fetch an element ...

Alternative to getElementById

Since the getElementById() function is new, I wanted another more reliable method to get a reference to an element based on its id. Since I need to cut down on size, 10-20K for a framework is unacceptable. I just need the JS to fetch an element. ...

How to store captured DOM events in C#

DOM events in WebBrower control (local instance of IE) can be captured by HtmlElementEventHandler, that are attached to HTML DOM Document Object after DocumentCompleted event is fired. How to store event that was fired, so that it could be invoked with InvokeMember() at later time. I am assuming that unique or pseudo unique tags and me...

Vista Sidebar Gadget not showing flyout - System.Gadget.Flyout.show not setting true.

I have a very strange bug going on. I cannot get the flyout to show on my gadget, despite having reproduced the flyout code character for character from a gadget that has a flyout that works fine. Here's the code: function doFly(i){ var div = 'div_' + i; flyHTML = $(div).html(); if (System.Gadget.Flyout.show == false){ System.Gadge...

Browser-independent way to detect when image has been loaded

In IE, you can onreadystatechange. There's onload, but I read scary things. jQuery wraps up the DOM's load event quite nicely with "ready". It seems likely I am just ignorant of another nice library's implementation of image loading. The context is that I am generating images dynamically (via server callbacks) that can take some time d...

JavaScript TextNode update

If I have a var t = document.createTextNode(text) parent.appendChild(t); Is it possible to simply update the contents of t? I would like to change the text inside the parent without using removeChild, createTextNode and appendChild. Why would I need this instead of just using innerHTML? Because I don't want to update the contents of ...

Why is the html attribute returned as 'htmldecoded' even if encoded in html source?

I use html attribute title to set some hints like this: <a href... title="Go to next chapter">Go</a> Then the jquery plugin goes through all the [title] attributes and makes pretty tooltips. Very simplified a new div is created for the link above <div style="position:absolute...">Go to next chapter</div> The problem is, that the ...

Dynamically insert an HTML string into the HEAD of a Document

I need to insert an HTML string into the <head> tag of the current document DOM, one way is: you create a div element, fill its innerHTML, copy over item-by-item into your <head> element. But these methods do not work in IE/Opera for reasons given below, though in FF3 both the below methods work perfectly, and the browser processes the a...

Data is invalid error when loading XML

I am trying to load a very basic XML document but everytime I get to the LoadXml(string url) line, the program crashes and reports an exception ("Data at the root level is invalid. Line 1, position 1" XmlException). XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(@"C:\Websites\TestHarness\TestHarness\TestHarness\ExampleXml.xml")...

How to iterate through all attributes in an HTML element?

I need the JavaScript code to iterate through the filled attributes in an HTML element. This Element.attributes ref says I can access it via index, but does not specify whether it is well supported and can be used (cross-browser). Or any other ways? (without using any frameworks, like jQuery / Prototype) ...

how to find coordinates of an HTML button or image, cross browser?

There was a thread on this in comp.lang.javascript recently where victory was announced but no code was posted: On an HTML page how do you find the lower left corner coordinates of an element (image or button, say) reliably across browsers and page styles? The method advocated in "Ajax in Action" (copy I have) doesn't seem to work in I...

Convert a DOM Node or Document to XML in JavaScript

Say you in JavaScript are handed a single DOM element or Document (for example window.document), how would you turn that into valid XML? More specifically for my example, I have a web page that display's an SVG, this SVG has a lot of JavaScript to allow interaction. It's a graph display that let's you zoom in the graph and even make som...

Nokogiri: Sort Array of IDs according to order in HTML document.

I have an unsorted Array holding the following IDs: @un_array = ['bar', 'para-3', 'para-2', 'para-7'] Is there a smart way of using Nokogiri (or plain Javascript) to sort the array according to the order of the IDs in the example HTML document below? require 'rubygems' require 'nokogiri' value = Nokogiri::HTML.parse(<<-HTML_END) ...

How to get this element using jQuery selectors?

I use jQuery to get values of presaved elements from some websites, using paths like this: HTML BODY #bodyContainer #mainContentContainer #mainContent #productContentRight #swatchContent #colorSwatchContent SPAN The problem i faced when the websites page contains tables and there are same element in another similar path such as: ...

IE not updating display after callpback pane updates the DOM

I have an update panel in an ascx page using .Net 3.5. The user enters data, initiates a callback, and ajax updates the DOM. Usually everything's all hunky dory. Once in a while the DOM gets updated and IE doesn't bother refreshing the display. The entire updated area appears to be blank. Once the user does something that would trigge...

Can I find out from a Javascript method, who\which DOM element called me?

<a onclick ="foo()" href="bar.html" >Link </a> <script> ... function foo(){ //I want to know the href property of whoever called me. //something like this.caller.href ?? } </script> I guess I could just assign all element IDs and then pass my own ID to the JS method I'm calling, but I was looking for a better way. ...

In XUL, how do I know a browser-tag has finished loading?

I'm developing a firefox extension based on this tutorial which is a FF 2.0 extension (second part of the tutorial is at this url) The main thing that is important is that it uses <iframe id="contentview" src="http://www.ibm.com/developerworks/web" flex="2"/> In the backend code, when clicking the GO button, this happens: contentvie...