Posts filed under ‘Javascript’

Insert a character using jquery at some location using substring


var count=$(‘.content’).length;
var before=$(‘.content’).text().substring(0,125);
var after=$(‘.content’).text().substring(125,count);
var result=before+’…’+after;


April 8, 2010 at 1:18 pm 1 comment

How to customize addthis plugin

Hey you need not to be PHP expert or javascript expert to customize addthis plugin. Just add this bit of snippet in the <head> tag

<script type=”text/javascript”>
var addthis_config = {
services_compact: ‘facebook, twitter, stumbleupon, digg, orkut, email, more’,

so keep adding rhe social networking sites names with comma separated and you are done.

Enjoy :), hope it helped

March 10, 2010 at 4:18 am Leave a comment

javascript browser detection script

// <![CDATA[
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var objId=document.getElementById("StageArea");
if ((browser=="Microsoft Internet Explorer") && (version

var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var objId=document.getElementById(“StageArea”);
if ((browser==”Microsoft Internet Explorer”) && (version<7)) {
if ((screen.width==1024) && (screen.height==768)){”472px”;”visible”;


else  {
if ((screen.width==1024) && (screen.height==768)){”472px”;



August 11, 2009 at 7:04 am Leave a comment

iframe change src | javascript

A small snippet for the people who wanna change src of Iframe on click.


<html xmlns=””&gt;

<script type=”text/javascript”>
function changeURL(id){


<form name=”testForm”>
<iframe id=”test” name=”testName” src=””></iframe&gt;
<a href=”#” onclick=”changeURL(‘test’);”>dfdfd</a>


July 27, 2009 at 3:56 am 8 comments

validating textarea using javascript/dhtml

So many times we need to validate textarea to limit users from entering more charachters

Here is the code which is tested  in IE for validating textarea for 255 charachters.

/*copy this code in head tag */

<script language = “Javascript”>
* Author : suresh kumar

function taLimit(taObj) {
if (taObj.value.length==maxL) return false;
return true;

function taCount(taObj,Cnt) {
if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
if (objCnt) objCnt.innerText=maxL-objVal.length;
return true;
function createObject(objId) {
if (document.getElementById) return document.getElementById(objId);
else if (document.layers) return eval(“document.” + objId);
else if (document.all) return eval(“document.all.” + objId);
else return eval(“document.” + objId);

/*copy this in body */

<font> Maximum Number of characters for this text box is 255.<br>
<textarea onKeyPress=”return taLimit(this)” onKeyUp=”return taCount(this,’myCounter’)” name=”Description” rows=7 wrap=”physical” cols=40>
You have <B><SPAN id=myCounter>255</SPAN></B> characters remaining
for your description…</font>

March 4, 2008 at 2:45 am 7 comments

Applying background to Iframe [IE / Firefox /Safari / Opera

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”&gt;
<html xmlns=””&gt;


function change_background() {
var iframeDoc;
if (window.frames && window.frames.subscribe && (iframeDoc = window.frames.subscribe.document)) {
// now use iframeDoc here’red’;

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>

<body onLoad=”change_background();”>
<iframe src=”test1.html” id=”subscribe” name=”subscribe” scrolling=”no” frameborder=”0″></iframe>


August 2, 2007 at 3:00 am 3 comments

Arrays / Populating arrays / Sorting in Javascript

<script language=”javascript”>
myarray=new Array(2);               //A array intialized of size 2
for(i=1; i<3; i++)                 //loop goes here
document.write(myarray.sort());         //sorting array elements

August 1, 2007 at 5:16 am Leave a comment

Older Posts

Flickr Photos

Blog Stats

  • 720,695 hits