Posts Tagged ‘javascript’

Setting the Cookie value through JavaScript

February 20th, 2011 No comments

These two functions will demonstrate how to set the value in cookie and get the value through java script

This function sets the value

function setCookie(){

var name= ‘Mycookie';
var value =’true';
var path = ‘/';

var today= new Date();
today.setTime( today.getTime() );

//expires in one day
var expires_date = 1 * 1000 * 60 * 60 * 24;

var expires = new Date( today.getTime() + (expires_date) );

document.cookie = name + “=” +escape( value ) +
document.cookie = name + “=” +escape( value ) +
( ( expires ) ? “;expires=” + expires.toGMTString() : “” ) +
( ( path ) ? “;path=” + path : “” ) ;


escape is used for decoding the value

This function retrieves the value form cookie Read more…

Categories: Uncategorized Tags:

Inheritance in javascript

September 7th, 2010 No comments

In Java Script , you do not see classes as in traditional programming like Java/C++. So does java script supports inheritance ?

Answer : Yes.

Java script uses prototype inheritance instead of classical inheritance. Some more helpful links and post to get better understanding.

Categories: Uncategorized Tags:

Button not disabled in Firefox and Chrome

August 29th, 2010 2 comments

When you try to disable any button in your web application using this javascript function


You may find that it will work in IE but on Firefox and Chrome.


From W3Scholl,

“Enabled” Property isn’t standard property of XHTML 4(It’s Microsoft standard.).

So the solution would be to add this piece of code

var obj = document.getElementById(‘buttonId”);
getLabel = function(elem){
if ( &&”label”) { = “disabledLabel”;
Dom.getElementsBy(getLabel ,’td’, obj);

Categories: Uncategorized Tags:

Invoking browser functions with JavaScript

May 14th, 2010 2 comments

Browser functionality can be disabled using the JavaScript. JavaScript has the ability to capture and handle the key events. We will look at couple of examples on how to trigger browser functionality using Java script.

Disabling new page event and ctr key event in browser

Following is the example which shows how to disable the ctrl + N (new page event) and back button in the browser.


<body onkeydown=”return
fnDisableNewPage(event)” >


<script> Read more…

Categories: Uncategorized Tags:

What are Callback functions ?

April 1st, 2010 1 comment

A callback function is one that is not invoked explicitly by the programmer; rather the responsibility for its invocation is delegated to another function that receives the callback function’s reference and instructions as to when to run the callback function.

This an excellent quote from wikipedia explaining callback

Think of it as an “In case of fire, break glass” subroutine. Many computer programs tend to be written such that they expect a certain set of possibilities at any given moment. If “Thing That Was Expected”, then “Do something”, otherwise, “Do something else.” is a common theme. However, there are many situations in which events (such as fire) could happen at any time. Rather than checking for them at each possible step (“Thing that was expected OR Things are on fire”), it is easier to have a system which detects a number of events, and will call the appropriate function upon said event (this also keeps us from having to write programs like “Thing that was expected OR Things are on fire OR Nuclear meltdown OR alien invasion OR the dead rising from the grave OR…etc., etc.) Instead, a callback routine is a sort of insurance policy. If zombies attack, call this function. If the user moves their mouse over an icon, call HighlightIcon, and so forth.

Callback functions are nothing new. They have been in C++, php . Most common usage these days you might find in javascript functions and iPhone programming.

Categories: Uncategorized Tags:

Performance issue in IE 7 java Script Engine

March 31st, 2010 No comments

In one of my earlier post  Performance Improvement with Firefox ,  I had mentioned how we had to switch to firefox for our application response time in IE.  Andres in his post Garbage Collection in IE7 heavily impacted by number of JavaScript objects and string sizes is sharing his experience with performance issue in IE 7 java Script Engine .  One of his key recommendations , Be careful with string allocations and objects in memory -> GC in IE7 performs really badly

There is another presentation by Frank on browser problem in AJAX application in which he used PushToTest TestMaker to drive an Ajax application on IE 6 and 7 and on Firefox 3. to find out why some Selenium tests of Ajax applications were running at 3 minutes while the same test on a different browser took 30 minutes. You can find the details here Browser problems in AJAX applications

Categories: Uncategorized Tags:

Open new tab instead of new window in Firefox

March 12th, 2010 No comments

We had a requirement in which we wanted to open an applet in a new tab instaed of new window.

Here is how to do it”, server[0], ‘height=1,width=1,left=1,top=1,status=yes,scrollbars=yes,resizable=yes’);

change this to”, server[0]);

This will open the applet in new tab. As soon as you remove sizing parameters, it will open as a new tab.

But there is one issues here. The focus is on the applet tab instead on main screen. Read more…

Categories: Uncategorized Tags:

Jquery Tutorial With Javascript

January 27th, 2010 No comments


Today JQuery is a buzz in every tinsel town. From the day web sites began coming into the world wide web space, developers are trying hard to please their users. Javascript arrived and it added spices in it. Developers began playing with javascript and created tens of thousand useful things for the users and made things interactive. But this comes with a price. Creating and maintaining javascript application requires a lot of patience and a lot of trial and error. On the top of this if we wanted to  write  a piece of javascript that creates effects and animation, we had make sure every thing is working and sometimes struggling with table, div, span bla  bla bla. JQuery came into the picture like life savior and it made our life very much comfortable. Just have a look at the piece of code written below :-

<script src=”jquery-1.3.2.js”></script>
<p>You click on me, I will come after “Introduction”</p>

You can download code examples used in this tutorial here jquery code examples

This is just beginning and it can bring a lot of fun on your website. Imagination is the only limit.


(1)   What is JQuery

(2)   Why use JQuery

(3)   How JQuery works

(4)   Creating effects with JQuery

(5)   JQuery with server side technologies (

(6)   Future of JQuery Read more…

Categories: Uncategorized Tags: