.

Posts Tagged ‘java script’

Font resizing using jQuery

// April 15th, 2009 // No Comments » // JavaScript

Font Resizing is a very common feature in many modern websites. This can be done very easily with jQuery. The following script uses cookies to save the user preference, so the user preference is saved. jQuery Cookie plugin is used for managing cookie using jQuery. So include that too.

the html for increase, decrease links

<div>
	<a href="javascript:void decreaseFont();" class="font-smaller" title="Reduce font size">-</a>
	<a href="javascript:void normalFont();" class="font-normal" title="Normal font size">0</a> 
	<a href="javascript:void increaseFont();" class="font-bigger" title="Increase font size">+</a>
</div>

Add the following code just before the tag.

(more…)

  • Share/Bookmark

Disable right-click contextual menu

// March 16th, 2009 // No Comments » // JavaScript

You can disable right-click contextual menu in your website using jQuery. Download and include jQuery library in your page and add the following code before the tag.
(more…)

  • Share/Bookmark

Create a portable slideshow for your website, blog, Myspace, etc from your picasa web album

// May 1st, 2008 // 2 Comments » // Tips & Tricks

Create a portable slideshow for your website, blog, Myspace, etc from your picasa web album..

Using Picasa Web Albums you can create a Flash slideshow to embed in your blog or webpage. Each slideshow features built-in playback controls, size options, and the ability to display captions.

To create and embed a slideshow:

  1. Sign in to your Google Account for Picasa Web Albums at http://picasaweb.google.com using your Google Account username and password.
  2. Click the My Photos link and select the album you’d like to make a slideshow.
  3. Click the Embed Slideshow link. This creates a Flash slideshow from the album you’ve selected. When you update this album, your slideshow is automatically updated to show the latest photos.
  4. To embed the slideshow, copy and paste the HTML code that’s shown into your blog or webpage.

Here is a sample album (My cats)

  • Share/Bookmark

File extension validation Javascript

// February 27th, 2008 // 1 Comment » // JavaScript

You can use this function to validate the extension of a file, for client side file upload checkes.

// You can specify the file type in the code "valid_extensions = /(.doc|.pdf)$/i;" .
//If you want to add .docx supprt simply add |.docx (ex:(.doc|.pdf |.docx| .your-extension) ) 

var valid_extensions = /(.doc|.pdf)$/i;
function CheckExtension(fld)
{
	if(fld.value) {
		if (valid_extensions.test(fld.value)){
			return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}
  • Share/Bookmark

Javascript for validating a date

// February 26th, 2008 // No Comments » // JavaScript

Javascript for validating a date.

Pass month, day, year as parameters. This function will return true if the date is valid.

// Author: arunmvishnu.com
function validDate(month, day, year){
	if(month =='0' || day =='0' || year=='0'){
		return false;
	}

	switch(month){
		case '1': //** jan
		case '3': //** March
		case '5': //** May
		case '7': //** July
		case '8': //** Aug
		case '10': //** Nov
		case '12': //** Dec

		if(day >=1 && day <= 31){
			return true;
		} else {
			return false;
		}

		case '4': //** APRIL
		case '6' : //** JUNE
		case '9' : //** SEPTEMBER
		case '11' : //** NOVEMBER
		if(day >=1 && day <= 30){
			return true;
		} else {
			return false;
		}

		case '2' : // Feb
		if(isLeapYear(year)){
			if(day >=1 && day <= 29){
				return true;
			}
		} else if(day >=1 && day <= 28){
			return true;
		} else {
			return false;
		}
		default:
			return false;
	}
}

function isLeapYear(year){  // Checking wdr a year is leap year or not
	if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)){
		return true;
	} else {
		return false;
	}
}

The full js file can be dodnloaded from here

  • Share/Bookmark