how to check whether element is visible on screen


Sometime we need to load some content when that element is visible on browser. So first we need to find whether that element is visible on the browser or not.
Below is the demo example :
Javascript function :
function isVisible(elem)
{
var TopView = $(window).scrollTop();
var BotView…

Advertisements

base64 decode using javascript


We can decode any string encoded using base-64 encoding.
The atob() method of window object used to to a decode data encoded using base-64 encoding.
Example :

window.atob(‘SGVsbG8gV29ybGQgISEh’);

Output : Hello World !!!

Use Facebook to Comment on this Post

base64 encode using javascript


We can encode any string to a encoded data (using base-64 encoding) string.
The btoa() method of window object used to to a encoded data (using base-64 encoding) string.
Example :

window.btoa(‘Hello World !!!’);

Output : SGVsbG8gV29ybGQgISEh

Use Facebook to Comment on this Post

literal tag in smarty


{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax. Anything within {literal}{/literal} tags is not interpreted, but displayed as-is. If you need template tags embedded in a {literal} block, consider using {ldelim}{rdelim} to escape…

How to create a fade-in fade-out hint box for an element


Here is the example of fade-in fade-out hint box for an element.   <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt; <html xmlns=”http://www.w3.org/1999/xhtml”&gt; <head> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js”&gt; </script> <style> .my_cust_css{border:1px solid #333; display:none; background:#09F; border-radius:5px; padding:5px; width:180px;} </style> </head> <body> <a href=”#” class=”jqury_hint” id=”first” rev=”hello this is test message.”>chandan</a> <br /><br /><br /><br /> <a href=”#”…

Create cookies from javascript


function SetCookie(cookieName,cookieValue,nDays,domain) { var today = new Date(); var expire = new Date(); if (nDays==null || nDays==0) nDays=1; expire.setTime(today.getTime() + 3600000*nDays); if(domain != ”){ document.cookie = cookieName+”=”+escape(cookieValue) + “;expires=”+expire.toGMTString()+”;domain=”+domain+”;path=/”; }else{ document.cookie = cookieName+”=”+escape(cookieValue) + “;expires=”+expire.toGMTString(); } }