dom

Changing textarea wrapping using javascript

For my small wiki application, I mostly need to have the textarea used to edit the contents to use soft (or virtual) wrapping. However, in some cases, not wrapping the content would be preferable. I thought I would do this by simply having a button to turn off wrapping. Here is the simplified code: <form name="wikiedit" action="[[scri...

Detecting clicks inside an iframe from outside?

Here is the scenario. There is content loaded in iframe from other site. I click to some link inside the iframe. Is it possible to catch somehow outside the iframe what is that link? UPDATE Since I recieved question if my intentions are pure, I would explain more on the use case. May be I started in wrong direction for this task. So,...

Does the onchange event propagate?

I'm using event delegation to listen for events lower in the DOM, but it's not working for an onchange event on a select box. Does the onchange event propagate or bubble up the DOM? Googling has failed in finding a conclusive answer. ...

Refactoring a function that uses window.open to use the DOM rather than write()

I have an application that uses window.open() to generate dynamic popups. Unfortunately, I've had trouble creating the content of the new windows using the standard DOM functions (createElement, appendChild), and I've gone to using document.write() to generate the page. Concretely, how can I go from this: function writePopup() { va...

jQuery document.createElement equivalent?

I'm refactoring some old javascript and there's a lot of DOM manipulation going on. var d = document; var odv = d.createElement("div"); odv.style.display = "none"; this.OuterDiv = odv; var t = d.createElement("table"); t.cellSpacing = 0; t.className = "text"; odv.appendChild(t); Is there a better way to do this using jQuery? I've bee...

How to keep jQuery from parsing inserted HTML?

Hello, Does anyone know how to stop jQuery fromparsing html you insert through before() and after()? Say I have an element: <div id='contentdiv'>bla content bla</div> and I want to wrap it in the following way: <div id='wrapperDiv'> <div id='beforeDiv'></div> <div id='contentDiv'>bla content bla</div> <div id='afterDiv...

Open/Close Icons

I'm doing some shennanigans with jQuery to put little plus/minus icons next to my expanders. Its similar to the windows file trees, or firebugs code expanders. It works, but its not specific enough. Hopefully this makes sense... $('div.toggle').hide();//hide all divs that are part of the expand/collapse $('ul.product-info li a').to...

getElementsByName in IE7

I have some code doing this : var changes = document.getElementsByName(from); for (var c=0; c<changes.length; c++) { var ch = changes[c]; var current = new String(ch.innerHTML); etc. } This works fine in FF and Chrome but not in IE7. Presumably because getElementsByName isn't working in IE. What's the best workaround? ...

How can I clone an entire Document using the Java DOM?

I'm looking for a reliable, implementation-independent way to clone an entire Document. The Javadocs specifically say that calling cloneNode on a Document is implementation-specific. I've tried passing the Document through a no-op Transformer, but the resulting Node has no owner Document. I could create a new Document and import the n...

Easiest way to sort DOM nodes?

If I have a list like this: <ul id="mylist"> <li id="list-item1">text 1</li> <li id="list-item2">text 2</li> <li id="list-item3">text 3</li> <li id="list-item4">text 4</li> </ul> What's the easiest way to re-arrange the DOM nodes to my preference? (This needs to happen automatically when the page loads, the list-order ...

Yahoo Widget appending Image

I'm developing a Yahoo Widget. Using Javascript I'm attempting to append an image to the current viewing window. The image is not displaying. Interestingly enough i added a few alert statements to show my variables and check my work and realized that the image is actually popping up, and then dissapeearing. Does anyone know what I'm ...

How would you prefer <script> elements handled?

Imagine the following. Html is parsed into a dom tree Dom Nodes become available programmatically Dom Nodes may-or-may-not be augmented programmatically Augmented nodes are reserialised to html. I have primarily a question on how one would want the "script" tag to behave. my $tree = someparser( $source ); .... print $somenode->...

How can I append a child node to an element in a DOM object?

<% Set xmlDoc = Server.CreateObject("MSXML2.DOMDOCUMENT") xmlDoc.loadXML( "<response />" ) Set node = xmlDoc.createElement("account") xmlDoc.documentElement.AppendChild node Set node = xmlDoc.createElement("type") node.Text = "TheType" xmlDoc.documentElement.AppendChild node Set node = Nothing %> This...

Testing objects for ancestor/descendent relationship in JavaScript or Jquery

I'm trying to come up with a reusable JS or jQuery function that would allow me to test if one object is a DOM descendant of another. I've seen a model of testing for $b.parents('nodename').length>0 Which is fantastic when you only need to check if an element is a child of any node by that name. But what about a specific node? You...

How can I access element attributes from an IXMLDOMNode?

Hi all, I'm building an XML DOM document in C++. My problem is this: I execute an XPATH query from an Element in my Document, which I know will return another Element. The elementPtr->selectSingleNode call returns an IXMLDOMNode. How can I gain access to the attributes of this node? Part of me wants to downcast the Node to an Element,...

Javascript invalidated after dom manipulation

My page has two components that depend on Javascript. On the left hand side, there is a attribute base navigation (abn). And the right hand side is the Result of the abn. There is an event handler for abn and an event handler for the result (both are on clicks) Whenever the user clicks on the abn, I do an ajax call which returns a json ...

Identifying list item index - which is a better approach?

I need to pick up list items from an list, and then perform operations like adding event handlers on them. I can think of two ways of doing this. HTML: <ul id="list"> <li id="listItem-0"> first item </li> <li id="listItem-1"> second item </li> <li id="listItem-2"> third item </li> </ul> Using the IDs- ...

Can I unit test the DOM?

Hello, We have a Ruby on Rails app that uses some javascript in the views. Since we have good test coverage on the rest of the app, we want to continue that here. The js we use manipulates the DOM to show/hide divs and perform incremental searching for a combobox selecting from a table. Does anyone know of ways to test DOM manipulati...

How do I select text nodes with jQuery?

I would like to get all descendant text nodes of an element, as a jQuery collection. What is the best way to do that? ...

jQuery object descendant filtering

Assuming I have a tree structure UL --LI ---INPUT (checkbox) And I want to grab the checked inputs, I would select $('ul li input:checked') However, I want to select the checked inputs of a specific object $myUL that doesn't have an ID. $myUL.children('li input:checked') returns all li's since children filters immediate childre...