dom

How can I get the untruncated text value of an <OPTION> element?

I have HTML output similar to this: <select> <option value="1">Item1 </option> </select> How do I use JavaScript to get the value "Item1 " (with the space) rather than "Item1"? In Internet Explorer all the properties I've tried, e.g. text, innerHTML, data, nodeValue return "Item1" instead of "Item1 ". Interestingly in Firefox, textC...

list selection Problem jQuery

Dear all I am using JQuery My list has following <div id="wrapper"> <ul id="testnav"> <li class="test1"><a href="/link">Heading</a> <ul> <li><a href="/link">Sub Heading</a></li> <li><a href="/link">Sub Heading</a></li> <li><a href="/link">...

When does reflow happen in a DOM environment?

What kinds of activities will trigger reflow of web page with DOM? It seems there are different points of view. According to http://www.nczonline.net/blog/2009/02/03/speed-up-your-javascript-part-4/, it happens When you add or remove a DOM node. When you apply a style dynamically (such as element.style.width="10px"). When you retriev...

JQuery delete DOM element after fading out

I want to delete an DOM element right after fading out. What I did so far is $(element).click(function() { $(this).fadeOut(500, function() { $().remove(this); }); }); But now I always get this error in Firebug: http://dl.getdropbox.com/u/5912/Jing/2009-02-04_1109.png I guess it is because the fadeOut function is not really done w...

MVC Framework - Server-side DOM manipulation

I'm building an MVC framework, and I'm looking for native solutions / frameworks / tag libraries to draw from or to replace my framework entirely. I'm interested in the following features specifically: server-side DOM manipulation server-side events (page reload, form submit, node insertion, etc.) traversing the DOM tree using css sel...

Add a link stylesheet dynamically in the <head>

Hello, How to add a link stylesheet reference to the head of a document ? I've found this code but it's not working with all browsers, it crashes my IE7 : var ss = document.createElement("link"); ss.type = "text/css"; ss.rel = "stylesheet"; ss.href = "style.css"; document.getElementsByTagName("head")[0].appendChild(ss); Thanks ...

Setting nodeValue of text node in Javascript when string contains html entities

When I set a value of a text node with node.nodeValue="string with &#xxxx; sort of characters" ampersand gets escaped. Is there an easy way to do this? ...

Handling events from HTML anchor tags in ExtJS

I have a large application built in ExtJS and am looking for the best way to handle custom events from anywhere in the application. For example I might want to put an anchor tag in some text in the application which will open a custom component in my app. At the moment I listen to clicks on the body and if the target has a css class appl...

Correct element.getElementsByTagName() implementation

//EDIT My issue was related to something else, I thought the implementation was incorrect but it actually works, thanks for the confirmation. Looked in jQuery and prototypejs, can't seem to find the way they implement getElementsByTagName on a element (not document.getElementsByTagName). Here's my test html: <div id="something" style=...

Cross-browser way to determine whether a DOM event was cancelled

Is there a cross-browser way from a javascript event handler to determine whether the event has been cancelled by a previous handler? IE and other browsers like Chrome etc. have an event.returnValue property that can be tested, but FireFox doesn't appear to have any such property. Here's an example of the scenario I'm talking about. You...

Javascript check box validation and length

Have check boxes 1-300. This JS function alerts user when nothing is selected. Function works great for the first 290 elements. For example, when item 291 is selected it alerts that nothing is selected. document.checks.user.length is coming out to 298, not sure why that is either. Any suggestions? Thanks. function sub_delete() //Submit ...

How can I check whether a variable is defined in JavaScript?

How to check whether a JavaScript variable defined in cross-browser way? I ran into this problem when writing some JavaScript utilizing FireBug logging. I wrote some code like below: function profileRun(f) { // f: functions to be profiled console.profile(f.constructor); f(); console.profileEnd(f.constructor); } It wor...

JSONML vs. InnerHTML vs. ?

First of all, am I the only person using JSONML? And second of all, would you recommend using JSONML for inserting dynamic HTML or is InnerHTML more efficient? ...

jQuery: selecting a parent attribute from a callback

Hello, given this html code: <td><img class='del' id='4' src='images/delete.gif'></td> I am in trouble understanding how to complete the following code: $(document).ready( function(){ setup(); } ); function setup(){ $("#deleteForm").hide(); $("img.del").bind('click', formDisplay); } function formDi...

What does "kill" do in JavaScript?

What does this JavaScript do exactly? parent.kill = 1; This is used in a project I'm working on to do some sort of session expiration but I've never seen it before. It's loaded in an iframe so I'm assuming that it is targeting the DOM document.window. ...

using jQuery after someone else's Javascript

Scenario: I have a Javascript-generated web page that someone else wrote a long time ago that I'd like to pretty up using jQuery. My goal is to clean up the Javascript generated html that someone else produces just by using some jQuery calls against that HTML, after it has been generated. This will be much simpler than modifying the ot...

Android TouchEvents DOM API

Is there a TouchEvents DOM API for Android? I need to implement drag & drop behavior. ...

Show url on link hover in AIR HTML control

Does anyone know if there is a simple way of catching the hovered link url in an AIR HTML control? Just like in a browser, I would like the url to be displayed in a status bar but I can't find any event that is raised on rollover of a link. Do you I need to inspect and perhaps manipulate the DOM myself for that? ...

In Javascript find if a checkbox is focused

In Javascript how can I tell if a checkbox has focus or not? I thought there would be a method or property called isfocused. But apparently not. By in focus I mean they've tabbed to it using the keyboard and at this point pressing space would check the box. ...

jQuery: Creating a DOM Element on the fly, but fading it in?

I'm having a problem creating a DOM element, appending it to another element, and having it fade into place. Obviously, this doesnt seem to work: $('<div/>').html('hello').appendTo('#parentDiv').fadeIn(); So, what is the proper way? ...