Improving interactivity with Javascript

HTML controls other than conventional Push buttons, radio buttons, check boxes, select boxes, and text inputs, can power up forms, webdev using javascript to increase interactivity and easy (for users). List of such controls includes : slider, Date picker, Smart text boxes, Advanced tooltips, Auto validation etc.

Read more friendly bit >> Improving interactivity with Javascript
In addition, I find image maps also very handy when it comes to intereactivity when used properly with tooltips…as i used them in Paint Chat.

Bonus link[ :) ] DailyBlogTips > Web 2.0 Webdesign Tutorials
Related post :

Firebug : web development evolved

I found firebug very useful while developing my Paint Chat (which is not a big code as such but still), so here it goes in admiration of firebug:

Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

Firebug is firefox addon that helps you in webdevelopment with
its powerful feature such as javascript debugger, Inspect and edit HTML, Tweak CSS to perfection, Monitor network activity, Explore the DOM and many more. Feature I like most is its quickly diagnosing problem, it allows you set break points and checking intermediate values of variable for javascript thus making a great javascript debugger. Many times you are stuck at where did the code went wrong so in way its a lot useful in saving time.

I also like is its inspecting html and modifying html and css on fly and see the results with helpful tooltips. It also help in positioning of divs, images with its nice feature of visuallizing css metrics with ruler and box model coloring(HTML inspecting).

It other great feature is its interface which is comes with browser window split in two halves one for your website and one is extension interface (though it also can be detached from it). I am also a fan of Web developer toolbar extension but what it lacks is a java debugger and this great interface but both are a must of a web developer.

Related Post :

Firebug - Web Development Evolved

Play with html using javascript

Javascipt can be very fruitful and flexible when it comes to modifying webapges dynamically (though client side). Javascript can be helpful in creating response to browser events like mouseup, mouseover etc, veryfying of form values prior to submitting them, changing style and value of html elements dynamically.
Examples i disscuss here are being user by me in developing Paint Chat !! So here I go..
You can write javascript functions and code in section as:

<script type="text/javascript">function test(){alert("test javascript");}</script>

Action on events:

Example of events can be mouseclick, keystroke, submitting form etc.
With onload()

 <body onload="init()">

Now init() function will be called when this html page is being loaded.
For links, javascript function can be evoked when clicking, mouseover over links like

 <a href="javascript:replay()" mce_href="javascript:replay()">Refresh ! </a>

Now function replay() will be called when Refresh! is clicked. For input text box

<input type="text" size="30" id="search" onchange="suggest()">; 

Now whenever content of textbox changes the function suggest() will be called. It can be useful when feature like google suggest has to be implemented or so.

On submitting forms:

<form method="post" action="some.php" onsubmit="return checkForm()">

So whenever this form is being submitted checkForm() function will be called and can be helpful in verifying values of form elements.

onMouseOver and onMouseOut:

<a href="http://www.aburad.com/blog" mce_href="http://www.aburad.com/blog" onmouseover="fade()"><img src="image.gif" mce_src="image.gif"> </a>

Now when mouse is over image fade() function will be called and can be used for animate and styling purposes.

Registering of events

A simple way can be:
Conside the html code : <div id="sample"> ..... some... html..text.. </div>
Now using javascript you can register event for this div by:

 var div_sample = document.getElementById('sample');div_sample.onmousedown=sampleMouseDown ; 

Now whenever mouseover ocours over this div html element sampleMouseDown() function will be called. Events can also be registered using addEventListener() . Find more information baout it here:Advanced event registration models

Modify Style and values for html elements

Within some javascript function, you can first get the element object by getElementByID() getElementsByName() for example conside the javascript code:

document.getElementById("colorcode").innerHTML = "#000000";
document.getElementById("bgtest").style.backgroundColor= "green";

The first line find the html element with id colorcode and then set its value to “#000000″ using innerHTML. In second line, it sets the background of html element with id “bgtest” to green.

Some other tweaks which were useful :

var intervalID = setInterval(drawCurve, 100);

So the drawCurve() function will be called repeatedly after 100ms. You can cancel this process( removing repeatedly calling) by clearInterval(intervalID);

var testImg = new Image();
testImg.src="form.php?name=form_value" mce_src="form.php?name=form_value";

Now here in form.php you can fetch value of variable name using $_GET and can perform appropriate action.

Some links:

Related Posts:

Paint Chat !!


Now chat using a paint brush !!.

I had made this app which uses paint brush to express yourself and share with others. This uses HTML:Canvas for drawing graphics using javascript, so no sluggish java applet and flash. It uses XMLHttprequest to synchronize paint screen with server. You can share this url with your friends to have a chat with paint brush and use Refresh !! to update your paint screen with that of your friend.
Read about Paint chat.
Try It out : Paint Chat

Updated: I have added feature for filling up whole background with color and also the transparency feature.

Related Post:
Shout-Box

funky javascript

Just paste the JavaScript given in you address bar after visiting any website.
Copy this to location bar & press enter.
——————————————————————————————–
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName(“img”); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position=’absolute’; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+”px”; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+”px”}R++}setInterval(‘A()’,5); void(0);
———————————————————————————————
This is what you get when you try it on search result from google images:

Related Links : Play with html using javascript
Little tweaks with javascript bookmarklet

Source : Digg.com

An Introduction to AJAX

AJAX (Asynchronous JavaScript and XML) is the latest boom in the Web development world. AJAX helps developers narrow the gap between desktop and web applications — Google Earth, Flicker and MS Outlook Express Web Version are some of the applications powered by AJAX.

Asynchronous means that you can make a request to a server and perform other actions while the server is processing your request — and on the arrival of the response required actions can be performed — as opposed to conventional web applications, in which the user has to sit back and stare at the blank screen while the server is processing the request.

AJAX Architecture :
Figure 2

Read More >>
Source : Topcoder

Secure Programming for Linux and Unix HOWTO

This book provides a set of design and implementation guidelines for writing secure programs for Linux and Unix systems. Such programs include application programs used as viewers of remote data, web applications (including CGI scripts), network servers, and setuid/setgid programs.

read more | digg story

Why Ruby on Rails Will Ultimately Dominate Software Development

The new 1.1 version of Ruby on Rails almost seems to drive the final nail into the coffin of .NET and J2EE. Enterprises will take their time but everyone else will start turning out great software. Includes rare video interview with Rails creator and detailed overview of Rails 1.1.

read more | digg story

Little tweaks with javascript : Bookmarklets.

A bookmarklet is a snippet of Javascript that can be bookmarked (or saved as a favorite) inside your web browser. Bookmarklets can enhance web pages, add special functionality using javascript which is supported by most browsers today and make your browsing experience a lot more efficient by offering one-click access. I will first start with basics.
Consider a simple javascript :

When you type this in browsers location bar then it will show a message box with “you clicked on the page” message. Now change this slightly :

Now this will repeatedly pop-up the message box in every 1-sec interval. Though this is of no use i’m just telling this to explain basics of javascript.

Now filling form with javascript :

Now this javascript will fill the value “someText” in field login_username of form in html page.
And lets try to take some user-input :

Now this javascript will first check if some text is selected on page. If no text is selected it will prompt user for text else will show an message box with selected text. Now we can put this script to some good use : like

Now this will search the selected text on my blog or if text is not selected than prompt user for text.

An equivalent script for searching on wikipedia is :

Now you can bookmark this script in toolbar so every tim you click on button in toolbar it will execute javascript. For example Drag this to your firefox bookmark toolbar :

Search Wikipedia

Some more bookmarklets :
Scale Images

Sort Table

Transpose Table

Show Password

So in a way they are different from bookmarks and provides extra functionality through power of javascript. Here are some more javascript bookmarklet
You can view source for each bookmarklet by viewing page source .
You can find more bookmarklets at : http://www.squarefree.com/bookmarklets/

See this helpful screencast on bookmarklets.

Some More Example at Wisdombay

Updated : For changing documenet backgrounds :
Change to Red
Change to green
Change to blue
This may not work with pages using css

Poster of History of Programming Languages

Poster of history of programming languages of 1954-2004.

read more | digg story

← Previous PageNext Page →