Archive for November, 2012

How to delete cookies in JavaScript

{0 Comments}

To delete cookies of a browser using JavaScript there are many ways which developer uses. Setting past date for expiry  One of popular practice is to overwrite the cookies expiration time and then set it some date that which have passed. So it will get removed after setting the session value to expired date. This …

Read More…

How to write cookies in JavaScript

{0 Comments}

Writing or setting the cookies using JavaScript is simple. You need use document.cookies command then after equal sign write cookies name and then cookies value after an equal operator as shown in the following code snippets  Javascript |  copy code |? 1Document.cookies=cookiesname=cookiesvalue;

Read More…

How to read cookies in JavaScript

{0 Comments}

To read cookies in a JavaScript following is the JavaScript function which will help you to read the particular cookies with the name which you have supplied in the function   Javascript |  copy code |? 01<script>02 03function readCookie(name) {04 05 var cookiename = name + "=";06 07 var ca = document.cookie.split(’;');08 09 for(var i=0;i < ca.length;i++)10 {11 12 var c = ca[i];13 14 while (c.charAt(0)==’ ‘) …

Read More…

Javascript code for alphanumeric validation

{0 Comments}

Following is the code for the alphanumeric validation in JavaScript   Javascript |  copy code |? 01<script type="text/javascript">02function alphanumeric(abc)03{04 var numaric = abc;05 for(var j=0; j<numaric.length; j++)06 {07 var alphaa = numaric.charAt(j);08 var hh = alphaa.charCodeAt(0);09 if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))10 {11 }12 else {13 alert("value entered is not …

Read More…

How to find div height in JavaScript

{0 Comments}

To get the height of div in JavaScript following is the powerful JavaScript function I found on Google which is giving the result. So you can get the height of the div by using following function.    Javascript |  copy code |? 01function GetHeight() {02 var oDiv = document.getElementById("MyDiv");03 var sOriginalOverflow = oDiv.style.overflow;04 var sOriginalHeight = oDiv.style.height;05 oDiv.style.overflow = "";06 oDiv.style.height …

Read More…

How to find checkbox is checked in JavaScript

{0 Comments}

To find if checkbox is checked or not then you can use checked term with checkbox id can be use to get Boolean value the “true”,”false”. In following code sample there is a variable which get the Boolean value according the status of checkbox. So you can use following code sample to check if checkbox …

Read More…

How to find current URL in JavaScript

{0 Comments}

If you need to get url of the same page loading in JavaScript then document.URL will help you, this will return the only the current URL as implemented in following code snippets  Javascript |  copy code |? 1var text=document.URL;2 document.write(text);3 If above code is not helping you then you can use following code snippet. In which Window.location.href because I found …

Read More…

How to find current date in javascript

{0 Comments}

To find Current date using JavaScript you need to use Date inbuilt function. But the thing which you will notice is that, date you are getting by using inbuilt Date function is not in the correct format so you need to customize the JavaScript according to yourself. Which will give you date in proper format. …

Read More…

How to find a character in a string in JavaScript

{0 Comments}

There are two methods which is much more widely used in JavaScript to finding some character or part of string. This is CharAt and indexOF. CharAT CharAT is JavaScript method which will help you to get the character at particular position like at first, or eight places.  Thing to remember that here count starts from …

Read More…