Is IE? Shortest JavaScript code to find whether the browser is Internet Explorer.

January 30th, 2009 by Sunil

There are a lot of JavaScript codes to find whether the user browser is Internet Explorer. But here is the shortest code to check whether the browser is Internet Explorer.

if(‘\v’==’v')

It will return true if you are using Internet Explorer.

So we can write the code like this.

1
2
3
4
5
6
7
8
<script type="text/javascript">
if("\v"=="v"){
	alert("This browser is Internet Explorer");
}
else{
	alert("This browser is not Internet Explorer");
}
</script>

A day at Guruvayur

January 30th, 2009 by Sunil

It was an ambition from long time to go to Guruvayur temple. Last Friday (23rd January 2009) we went there with our family.

Friday night we started from Trivandrum. The train (Guruvayur Express – Train No: 6127) was little bit late (it supposed to be start at 23:35) and it started at Midnight only. The train bound for Guruvayur directly.

Guruvayur

We reached Guruvayur at 7 AM. But it was not easy to take a room on Saturday. Because the next day a lot of marriages happening at Guruvayur temple. Most of the hotels have already been reserved. But luckily we got a room near to west side of the temple.

Punnathoorkotta (Anakottil otherwise known as Anakotta)

After visiting the temple we went to Anakottil (otherwise known as Anakotta or Punnathoorkotta) near to temple. It is about 3 and half Kilometers from the Guruvayur temple. Anakottil is using as the shelter for elephants. This place is belonging to the Guruvayur temple. There are currently 64 elephants housed there, all offerings from by devotees of Lord Guruvayurappa, and they are trained there as well.

After visiting the Punnathoorkotta, we went back to Guruvayur, stayed there at that night after visiting the temple once again.

Early morning we again visit the temple. And we started from there to our house. The train (Netravati express, Train No: 6345), was on time and we reached trivandrum at 6.15 pm.

We reached safely and happily.

I have updated the photos on flickr. Please have a look.

A "Female Asian Koel" in my house

January 17th, 2009 by Sunil

Today one rare bird came to my house. It was around 07.30 PM and my mother and wife were watching television. Suddenly one bird came to my house. It has white dots on his feather and eyes were red. We got feared because it has sharp nails and bills. I think its name is “Female Asian Koels” in Malayalam its name is “Pulli kuyil”. Here I am attached the photo of the bird. You can find the details from here. (http://en.wikipedia.org/wiki/Asian_Koel)

Asian Koel

Asian Koel

This time, one of our neighbours came to our house. He catches the bird with his towel. And he took the bird out. After some time it flew away from the courtyard.

How to make a colour scheme for your website using JQuery and CSS

January 17th, 2009 by Sunil

It is an interesting thing that if we see some changes on a website, both content wise and layout or colour wise. So I decided to add a colour scheme to my blog.So the visitors can select a colour scheme from these buttons. Have you notice the 6 buttons in this page on the header portion?

Select colour scheme

First of all I have placed 6 buttons on the header portion of this blog for the visitors to select their choice. viz
1. SeaGreen, 2. Brown, 3.Blue, 4. Orange, 5. Green, 6. Pink.

So the html will look like this.

1
2
3
4
5
6
7
8
<div id="skin-select">
<a href="#" title="SeaGreen" class="seagreen">SeaGreen</a>
<a href="#" title="Brown" class="brown">Brown</a>
<a href="#" class="blue" title="Blue">Blue</a>
<a href="#" title="Orange" class="orange">Orange</a>
<a href="#" title="Green" class="green">Green</a>
<a href="#" title="Pink" class="pink">Pink</a>
</div>

2nd Step
We need to make the changes on CSS file. I have added skin.css to my main css via import statement like @import url(“skin.css”);

In the skin.css I have added the colors where ever I need to change the background color, font color or border.

3rd step
Now come the javascript part. I am using the JQuery frame work. I like Jquery very much. So we need to include the jquery framework to our page and we need to write custom javascript code for its working. For that I added script.js to my page.

In the script.js I added the following code in the document.ready function.
$("#skin-select a").click(function(){
if($("body").attr("class")){
$("body").removeClass($("body").attr("class"));
}$("body").addClass($(this).attr("class"));
});

What this code will do?

When clicking each button it will add a class to body. If the body already has a class, it will remove the existing class and add a new class with new color name.

If your css is right it will work fine on each click.

What is next?

If you close the browser and open the it again with the same url, you can see the default colour scheme only. But I would like to see the colour scheme which I have recently opted.

For that we need to save this information in your computer. I have added a Jquery plugin for saving this colour scheme to the computer. A cookie is information that a Web site puts on your hard disk so that it can remember something about you at a later time. So I have added a jquery plugin for saving cookie.

Now we can save the latest color scheme to our visitor’s machine. So next time when he opens the site he can see the latest colour which he has selected in the last.

So the final code will look like this.
$(document).ready(function() {
if($.cookie('theme_color')!= null)
{
var coockiecolor = $.cookie('theme_color');
$("body").addClass(coockiecolor);
}
$("#skin-select a").click(function(){
if($("body").attr("class")){
$("body").removeClass($("body").attr("class"));
}
$("body").addClass($(this).attr("class"));
var colorname = $(this).attr("class");
$.cookie('theme_color', colorname, { path: '/', expires: 10 });return false;});
});

Inside the document.ready function first it will check whether any cookie saved for theme or not. If it is available it will take the theme information from the cookie. You can check the documentation about jQuery cookie in detail can be find here.

What do you think now? Is it easy? Waiting for your valuable feedback.

Does the page rank really matter?

January 11th, 2009 by Sunil

There was a recent page rank update from Google on this December. Many of the SEO people may notice that. Some websites got a better page rank and some websites lost their existing page rank. 

What are real factors that affect the page ranking? (Really I don’t know!)

According to the words of Google, “PageRank reflects our view of the importance of web pages by considering more than 500 million variables and 2 billion terms. Pages that we believe are important pages receive a higher PageRank and are more likely to appear at the top of the search results.”

And Google is saying that it depends on the links of the page and other links which are coming to the website. (Incoming links). 

google-pagerank

But the last update from Google was not on this policy? I hosted this blog around 1 and half months back only (28th of November). I don’t have much incoming links. But I got page rank 3. But some good sites which have a lot of incoming links lost their page rank. Any of them could find any reason for this? What do you think? 

Now I am feeling like that Google page rank is not a big thing…You may miss the page rank at any time? Build your web page for your visitors not just for search engines!

Pushup – advice your visitors to upgrade their browser

January 9th, 2009 by Sunil

It is an interesting thing that pushup javascript will tell the visitors that they have to upgrade their browsers to the  latest one if they are using the  old browsers.

It is easy to install and customisable

Upload the pushup package in to your server
Include the pushup.css and pushup.js in to your page header.

Pushup shows warning in firefox

Pushup shows warning in firefox2

Pushup shows warning in ie6

Pushup shows warning in ie6

If you want to upload this package other than the js directory, change your css background image path accordingly. More information available here (http://www.pushuptheweb.com/)

Download latest pushup can be download from here (http://github.com/staaky/pushup/tree/master)

Currently pushup can be integrated with the following frame work

Open links in new window automatically in WordPress using JQuery

January 6th, 2009 by Sunil

Sometimes we need to open the external links automatically in our websites. Here I am adding a small snippet for that. JQuery is JavaScript framework using for that. So first you need to include Jquery framework to your page.

For that either you need to download the jquery and add it your page, or you can link directly load the framework using Google code

How we can include JQuery using Google code
Check out this link
http://code.google.com/apis/ajaxlibs/documentation/index.html

Benefits of including JQuery from Google code

  1. It saves on bandwidth
  2. It will load quickly from Google’s CDN.
  3. It will already be cached if the user has visited a site which delivers it from Google code.

Ohh.. I am going out of the subject. Ok, After including Jquery you need to write the below code either in your separate Javascript file or your in the html page.
$(document).ready(function() {
$("a[@href^=http]").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}})
});

If you want to add a class on external links for styling differently or add a background to it? It is easy. Just add this code. It will add a class to your external links.
$(document).ready(function() {
$("a[@href^=http]").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
$(this).addClass(‘external’);
}})
});

I am using this code in my blog. It works well. If you find any bug on it, Please let me know.

[update]

Today I added $(this).attr('rel', 'external nofollow');

So Google may not follow any external link. Now the script should look like this


$(document).ready(function() {
$("a[@href^=http]").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
$(this).attr('rel', 'external nofollow');
}}
)});

Mammootty starts blog

January 5th, 2009 by Sunil

I was searching on Malayalam fonts and Malayalam blogging things today. Eventually I came around this blog! http://i-am-mammootty.blogspot.com/ . Mammotty is a well known Indian actor, popularly known as Mammokka.

He started his blogging on 1st January 2009 and came up with some serious writing on socio- political- financial issues plaguing Kerala. Blog inaugurated on the location of his new movie “ee pattanathil bhootham”.

In his blog Mammotty shares his fretfulness about the recession. A lot of Malayalees reading his blog and he is getting a good response.

It is the good thing that normal people can interact with Mammotty through his blog.

Mammotty's blog

Mammotty's blog

View Mammotty’s profile on blog spot