dhtml

How do I add a div and pick it up later

I think this is specific to IE 6.0 but... In javascript I add a div to the dom...I assign an ID attribute. When I later try to pick up the Div by the ID all I get is null??? Any suggestions? Example: var newDiv = document.createElement("DIV"); newDiv.setAttribute("ID", "obj_1000"); document.appendChild(newDiv); alert("Added:" + newD...

Best server-side framework for heavy AJAX Java application

There are zillions of Java web application frameworks. 95% were designed before the modern era of AJAX/DHTML-based development, and that means these new methods are grafted on rather than designed in. Has any framework been built from the ground up with e.g. GWT + Extjs in mind? If not, which framework has adapted best to the world of...

Best Javascript drop-down menu?

I am looking for a drop-down JavaScript menu. It should be the simplest and most elegant accessible menu that works in IE6 and Firefox 2 also. It would be fine if it worked on an unnumbered list (ul) so the user can use the page without JavaScript support. Which one do you recommend and where can I find the code to such a menu? ...

What features distinguish Flex from DHTML?

I just got started using Adobe Flex SDK. I was very excited because it's the first time I've found a good, free way to create Flash applications. But then I noticed something: Flex doesn't seem to be much about making animations or designs. It seems more like an application to build forms and menus and the like... which I can already ...

Trigger button click with JavaScript on Enter key in Text Box

I have one text input and one button (see below). How can I use JavaScript to trigger the button's click event when the Enter key is pressed inside the text box? There is already a different submit button on my current page, so I can't simply make the button a submit button. And, I only want the enter key to click this specific button i...

Is JavaScript single threaded? If not, how do I get synchronized access to shared data?

I have a web page with DIVs with a mouseover handler that is intended to show a pop-up information bubble. I don't want more than one info bubble to be visible at a time. But when the user moves the mouse rapidly over two items, I sometimes get two bubbles. This should not happen, because the code for showing a pop-up cancels the previou...

Character offset in an Internet Explorer TextRange

As far as I can tell there's no simple way of retrieving a character offset from a TextRange object in Internet Explorer. The W3C Range object has a node, and the offset into the text within that node. IE seems to just have pixel offsets. There are methods to create, extend and compare ranges, so it would be possible to write an algorith...

Limit displayed length of string on web page

I'm looking for a technique (javascript, CSS, whatever ???) that will let me control the amount of a string that is displayed. The string is the result of a search (and therefore not initially known). A simple Character count approach is trivial, but not acceptable, as it needs to handle proportional fonts. In otherwords if I want to lim...

Is there a good in-browser code editor?

We've all seen in-browser rich text editors, which allow you to edit colored/styled text in a WYSIWYG manner. But what about code editors, which automatically highlight code based on language rules as you type? Think Eclipse in a textarea (but without the refactoring support). Do such things exist? I imagine scaling would be a problem -...

JavaScript library to create div-style window within page

Im trying to find out a good JavaScript library that can create a nice "inner-window" popup within a page on my site. I would like to not have to worry about screen positioning (i.e. dont have to calcuate if the size of the window will be off screen, etc...), but just make a new pop-up that has content in it. I'll be using .NET 3.5 ASP...

"Endless scrolling" effect in a HTML table

I am displaying a scrolled data table in a web page. This table has several thousands of dynamic rows, so it is loaded from the server (via AJAX). The user can scroll up and down, so what I need is to detect when the user reaches the end of the scrollbar (that is, the last row at the bottom of the table) in order to request and show mo...

Is there a best practice for generating html with javascript

I'm calling a web service that returns an array of objects in JSON. I want to take those objects and populate a div with html. Let's say each object contains a url and a name. If i wanted to generate the following html for each object: <div><img src="the url" />the name</div> Is there a best practice for this? I can see three w...

What is the best JavaScript code to create an img element

I want to create a simple bit of JS code that creates an image element in the background and doesn't display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 =< only. Here is the code I have: var oImg=document.createElement("img"); oImg.setAttribute('src', 'ht...

Good Javascript Combo Box replacement for combo boxes with tons of elements?

I have a page where my combo box has hundreds of elements which makes it very hard to pick the one item I want. Is there a good Javascript replacement that would do better than <select id="field-component" name="field_component"> <option selected="selected">1</option><option>2</option>... </select> Is there somethin...

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...

Paging Alternatives

I'm working on a project that returns paged results with volumes potentially in the hundreds of pages. I've been playing around with more usable ways to perform paging than the standard fisrt/last/next/previous links and jump-to text box. One alternative I had was to have a scrolling list of pages. I'd display 5 to 7 links at a time, cen...

How can I dynamically create the source for a frame using javascript?

Suppose I have one html page with frames. The left frame is simply a list of links, which will be displayed in the right frame. Is it possible, using javascript, to generate the contents of the left frame when the page loads? ...

Get the position of a div/span tag

Can someone show me how to get the .top & .left position of a div or span tag when one is not specified? ie: <span id='11a' style='top:55px;' onmouseover="GetPos(this);">stuff</span> <span id='12a' onmouseover="GetPos(this);">stuff</span> In the above, if i do: document.getElementById('11a').style.top The the value of 55px is ret...

How do I retreive an HTML element's actual width and height?

Suppose that I have a <div> that I wish to center in the browser's display (viewport). To do so, I need to calculate the width and height of the <div> element. What should I use for maximum browser compatibility? Looking for a solution that works on IE6+, FF2+, Opera and Webkit-based browsers (Safari 3+, Google Chrome). ...

Any way to shuffle content in multiple div elements

I'm relatively new to Javascript and was wondering if there's a quick way to shuffle content that is contained in multiple <div> tags. For example <div id='d1'> <span>alpha</span> <img src='alpha.jpg'> </div> <div id='d2'> <span>beta</span> <img src='beta.jpg'> </div> <div id='d3'> <span>gamma</span> <img src='gamma.jpg'> <...