dom

Dojo addOnLoad, but is Dojo loaded?

I've encountered what seems like a chicken & egg problem, and have what I think is a logical solution. However, it occurred to me that others must have encountered something similar, so I figured I'd float it out there for the masses. The situation is that I want to use dojo's addOnLoad function to queue up a number of callbacks which ...

IE caches dynamically added iframe. Why, and how do I prevent it?

I have the following HTML / JS: <html> <body> <script> function foo(){ var html = "<iframe src=\"foo.html\" />"; document.getElementById('content').innerHTML=html; } function bar(){ var html = "<iframe src=\"bar.html\" />"; document.getElementById('content').innerHTML=html; ...

Does jQuery have an equivalent to Prototype's Element.identify?

Is there a built in method or defacto default plugin that will let you automatically assign an unique ID to an element in jQuery, or do you need to implement something like this yourself? I'm looking for the jQuery equivalent to Prototype's identify method Here's an example. I have some HTML structure on a page that looks like this <...

Is a DOM Text Node guaranteed to not be interpreted as HTML?

Does anyone know whether a DOM Node of type Text is guaranteed not be interpreted as HTML by the browser? More details follow. Background I'm building a simple web comment system for a friend, and I've been thinking about XSS attacks. I don't think filtering or escaping HTML tags is a very elegant solution--it's too easy to come up w...

Using MSHTML for the GUI in C++, is there perhaps a tutorial?

I would like to migrate my app to using MHTML for the GUI since it would be much easier to experiment with layouts without rewriting the C++ every time. Is there a tutorial? What I found is unfortunately not what I need, which is: Feed it HTML from memory Receive events such as onclick, etc., back in my C++ code Manipulate it through ...

How to check null objects in jQuery

I am using jQuery, I want to check existence of an element in my page. I have done following code, but its not working? if ($("#btext" + i) != null){ //alert($("#btext" + i).text()); $("#btext" + i).text("Branch " + i); } Please tell me what will be the right code? Thanks ...

VB 2008 Express Replace string inside of Javascript on page loaded into axWebBrowser

I am using VB 2008 express and would like to know If i can Replace a string inside of Javascript on page loaded into axWebBrowser so i can then execScript that function. The specific string i wish to replace is "_new" to "_self" this is so when i call the function it will load in the same page instead of poping into a new web browser. ...

JQuery - making code execute for each new DOM object instantiated

I'm wondering if this is possible in JQuery. I have some Javascript code that creates DOM objects on the fly, in response to user actions. Some of those DOM objects are in a specific structure - the container always has the same "class" attribute. What I'd like to do is, every time a new instance of a DOM object with class "X" is creat...

JQuery to check for duplicate ids in a DOM

I'm writing applications with ASP.NET MVC. In contrast to traditional ASP.NET you're a lot more responsible for creating all the ids in your generated page. ASP.NET would give you nasty, but unique ids. I'd like to add a quick little jQuery script to check my document for duplicate ids. They may be ids for DIVS, images, checkboxes, butt...

Replace HTML page with contents retrieved via AJAX

I have an HTML page with a typical structure: <html> <head> <script .../> <style .../> </head> <body> content </body> <script> var success_callback = function(data) { // REPLACE PAGE CONTENT & STRUCTURE WITH "data" } ajax(url, params, success_callback); </script> </html> Do you think it is possible ? I've alre...

Java/DOM: Get the XML content of a node

Hi there! I am parsing a XML file in Java using the W3C DOM. I am stuck at a specific problem, I can't figure out how to get the whole inner XML of a node. The node looks like that: <td><b>this</b> is a <b>test</b></td> What function do I have to use to get that: "<b>this</b> is a <b>test</b>" ...

Best way to get the Original Target

What's a jQuery like and/or best practices way of getting the original target of an event in jQuery (or in browser javascript in general). I've been using something like this $('body').bind('click', function(e){ //depending on the browser, either srcElement or //originalTarget will be populated with the first //element that in...

Why some object doesn't have constructor in IE?

Below javascript has different effect in different browsers. document.write(this.location.constructor); document.write("<br/>"); document.write(this.constructor); document.write("<br/>"); In Chrome, the page has function Location() { [native code] } function DOMWindow() { [native code] } In Firefox, the page has [object Location]...

Performance of XML dom and the proper usage thereof

I hear all these bad things about the DOM.. Don't use the Activex object, XmlDom, or is it "dom".. oh God you are using the DOM? What is the straight on this usage. But we use document.GetElementbyId and ...Name all the time.. So what am I actually using when invoke these methods? Is this is what the browser is uing... The company ...

Is there a way to get a non-node result from MSXML XPath evaluator?

I understand that the name of selectNode/selectSingleNode methods actually suggests that they are designed to return a node, however maybe there is some other way or a setting available to enable XPath evaluator to return data of other types (that are also valid XPath results) oDocument.selectSingleNode("'1'"); throws an error "Expr...

Creating XML in C++ Code

In my project there are situations where we have to send xml messages (as char *) among modules. They are not really large ones, just 10-15 lines. Right now everybody just creates the string themselves. I dont think this is the right approach. We are already using xerces DOM library. So why not create a Dom tree, serialize it, and then s...

How do I create a new DOM element from an HTML string using built-in DOM methods or prototype

I'm trying to create an element dynamically using an HTML string. Here's a simple example using both prototype and DOM: // HTML string var s = '<li>text</li>'; // DOM var el1 = document.createElement(s); // prototype var el2 = new Element(s); $('mylist').appendChild(el1); $('mylist').appendChild(el2); Both approaches insert an empty ...

How do I find out which Javascript element has focus?

I would like to find out, in Javascript, which element currently has focus. I've been looking through the DOM and haven't found what I need, yet. Is there a way to do this, and how? Edit: The reason I was looking for this: What I'm trying to do is make keys like the arrows and enter navigate through a table of input elements. Tab works...

Javascript DOM - add form element to newly created appendChild?

I have two functions to add and remove table rows that contain a form input element. They both work fine, but I have a problem in that I need to show a Remove button input only on subsequently created table rows. My two function are as as follows: function addRow(table_id){ var clone; var rows=document.getElementById(table_id).getElemen...

how to show a 'working' indicator while inserting a big numbers of dom elements

While creating and inserting dom element's, it seems that the fuctions used for the task are returning before the elements show in the page. Before starting to insert the elements i set the display property of a div to 'block' and after inserting the elements i set the property to 'none', the problem is, the indicator is not showing in ...