ANIL KUMAR PANIGRAHI 's Blog

File for ‘JavaScript’ Category

How to detect the javascript is enable or disable?

Posted by: Anil Kumar Panigrahi in: ● August 17, 2009

Hi friends,
if the one site most of functionality in javascript, if the browser is disable the javascript, then total site will not working, to detect the that the javascript is disable or not, to that following code will work:
<noscript>
    Javascript is disable, please enable to access the site.
</noscript>

Simple tooltip using javascript and css?

Posted by: Anil Kumar Panigrahi in: ● August 4, 2009

The following code will generate the simple tooltip using Javascript and css.
The Javascript code :
<script language=”javascript” type=”text/javascript”>
/* This tooltip library was created by Anil Kumar  */
function showtip(e,message)
{var x=0;
var y=0;
var m;
var h;
if(!e)
var e=window.event;
if(e.pageX||e.pageY) { x=e.pageX;  y=e.pageY;  }
else if(e.clientX||e.clientY)
{ x=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;}
m=document.getElementById(‘mktipmsg’);
if((y>10)&&(y<450))
{  m.style.top=y-4+”px”;  }
else{  m.style.top=y+4+”px”;  }
var messageHeigth=(message.length/20)*10+25;
if((e.clientY+messageHeigth)>510)
{  m.style.top=y-messageHeigth+”px”; }
if(x<850) { m.style.left=x+20+”px”;  }
else{  m.style.left=x-170+”px”;  }
m.innerHTML=message;m.style.display=”block”;m.style.zIndex=203;
}
function hidetip(){
var m;
m=document.getElementById(‘mktipmsg’);m.style.display=”none”;
}
</script>
The CSS Code:
<style type=”text/css”>
#mktipmsg [...]

To disable the right click on the webpage?

Posted by: Anil Kumar Panigrahi in: ● April 29, 2009

Hi friends,
After working hard to complete your  design and images  ,some persons just save that images and web pages.
This is one  idea to disable the right click on webpage.
just put a small javascript code at the place between the head section.
*************************
<SCRIPT LANGUAGE=”JavaScript”>
<!– Disable
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function (“return false”)
document.oncontextmenu=new Function (“return false”)
//if NS6
if [...]

To count the characters in a textarea

Posted by: Anil Kumar Panigrahi in: ● April 27, 2009

Hi frineds ,
This is a simple script but we are using sometimes.
In the header section of the page:
**********************************
<!– Start the Script  –>
<script language=javascript>
//Edit the counter/limiter value as your wish
var count = “125″;   //Example: var count = “143″;
function limiter(){
var tex = document.myform.comment.value;
var len = tex.length;
if(len > count){
tex = tex.substring(0,count);
document.myform.comment.value =tex;
return false;
}
document.myform.limit.value = count-len;
}
</script>
<!– end of Script  [...]


About Me

  Anil Kumar Panigrahi
  Software Engineer (PHP)
  Blogger & Founder of Anil Labs
  Baruva, India

You can share with me . . .

My Own Contributions

1) First contribution for codeigniter framework ( multi language support using google translate API ). we can get files from http://github.com/nyros/codeigniter_multilanguage


2) Audio and Video Streaming using FFMpeg and PHP -complete doc file : http://www.docstoc.com/docs/8300349/Audio-and-Video-Streaming

Twitter Updates

Follow me @anil2u
  • We will always be thankful to our teacher for all the hard work and efforts they have put in, for educating us.- Happy teachers Day . . . :) - posted on 05/09/2010 05:39:13
  • Working on shipping cost functionality (UPS and USPS) for oscommerce shopping cart - posted on 01/09/2010 09:40:03
  • If your freedom hurts others, you are not free. You must not hurt others. - Vivekananda - posted on 31/08/2010 06:02:49
  • Another day starts with full of energy . Good Morning - posted on 31/08/2010 02:54:12
  • Nice explanation about php oops concept : http://youropensource.com/projects/182-OOPS-Concepts-in-PHP - posted on 30/08/2010 19:56:17