Category ‘JavaScript’ (page 2)

Image hover using Javascript

Monday, 08.06.2009.

In this post you will see how to implement image hover with iframe and div. My first try was with div and AJAX. Unfortunately in IE6, select (drop down menu) always stays on top of the hover image. Good old iframe is solution not only to put behind a select element in IE6, but to fetch a content without AJAX.

No responses yet

AJAX progress bar

Thursday, 14.05.2009.

With few lines of JavaScript and CSS you can make simple AJAX progress bar. JavaScript will periodically ask for progress value and server will respond with XML. Progress value should be extracted from the XML and displayed as width of the DIV element.

29 responses so far

Adding table rows & columns in JavaScript

Friday, 08.05.2009.

With insertRow() method you can insert a new row at the specified position in HTML table. After row is created, use insertCell() method to insert a table cell. Wrap this methods in JavaScript functions and you have code to dynamically add new rows and columns in the HTML table.

6 responses so far

Drawing with JavaScript

Thursday, 30.04.2009.

This post shows how to implement simple JavaScript drawing. After page is loaded, JavaScript will generate HTML table and attach onMouseDown and onMouseOver event handlers to the each table cell. When user clicks the left mouse button and move mouse pointer over table cell, table cell will change background-color property.

5 responses so far

Drag and Drop table content with JavaScript

Monday, 06.04.2009.

Content of HTML table cells can be dragged to another table cell or another table. It isn't difficult to define onMouseMove handler and change top / left element styles to move the object. In case with tables, you will have to determine somehow destination table cell. Attaching onMouseOver handler on table cells will not work, because browser doesn't fire events to the elements beneath the dragged object.

329 responses so far

Date shift in JavaScript

Friday, 30.01.2009.

Date shift in JavaScript can be done by counting days of the month and thinking of 28 or 29 days in February. Don't forget the year. This is a long and complicated algorithm. I suggest a simpler solution. Transform date to the number of milliseconds, and make easy arithmetic with integers. After addition and subtraction, create date from the milliseconds.

No responses yet

JavaScript fade menu

Thursday, 29.01.2009.

You can find a lot examples of JavaScript fade menu, but my goal was to make it short and simple - only 15 lines (if you don't count comment lines). First JavaScript function will initialize event listeners, while second will recursively change opacity level. It should work on FireFox and Internet Explorer.

3 responses so far