Back btn for iframe

<iframe name="codeframe" src="http://FILEURL" style="width:100%; height:60%; background:#fff;"></iframe>
<a href="#" onClick="codeframe.history.go(-1);">back</a>

Jquery UI Calendar with From and To

<div>
<label for="sdate">Traveling Start Date</label>
<input type="text" name="from" id="from">
</div>

<div class="clear"></div>

<div>
<label for="edate">Traveling End Date</label>
<input type="text" name="to" id="to">
</div>

<script>
$(function() {
var dates = $( "#from, #to" ).datepicker({
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
</script>
<div>

Detect Keystrokes

var isCtrl = false;
document.onkeyup=function(e){
if(e.which == 17) isCtrl=false;
}
document.onkeydown=function(e){
if(e.which == 17) isCtrl=true;
if(e.which == 32 && isCtrl == true){
//Your keystroke code here;
return false;
}
}

var keys = [];
function checkKey(e){
if (e.keyCode == 84){
if (navigator.appName == "Microsoft Internet Explorer")
e.returnValue = false; //works with Explorer
else {
//deal with Navigator or Mozilla
str = document.theForm.theText.value;
if (str.length == 1)
newstr=" ";
else {
newstr = str.substring(0, str.length -1);
}
document.theForm.theText.value = newstr;
}
}
else {
alert ("You entered the character " + String.fromCharCode(e.keyCode) + ".");
}
}

/* This is the html for the second function
<form>
<input type="text" name="theText" onKeyDown="checkKey(event);">
</form>
*/

Javascript print_r

function print_r(theObj){
if(theObj.constructor == Array || theObj.constructor == Object){
document.write("<ul>")
for(var p in theObj){
if(theObj[p].constructor == Array || theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
document.write("<ul>")
print_r(theObj[p]);
document.write("</ul>")
}else document.write("<li>["+p+"] => "+theObj[p]+"</li>");
}
document.write("</ul>")
}
}

Cross browser javascript events

/* ~~~~~~~~~ Event Functions ~~~~~~~~~ */

function hypEventDispatcher(){ this.events = []; }

//Add Event Listener
hypEventDispatcher.prototype.addEventlistener = function(event,callback){
this.events[event] = this.events[event] || [];
if(this.events[event]) this.events[event].push(callback);
}
//Remove Event Listener
hypEventDispatcher.prototype.removeEventlistener = function(event,callback){
if(this.events[event]){
var listeners = this.events[event];
for(var i = listeners.length-1; i>=0; --i ){
if(listeners[i] === callback){
listeners.splice(i,1);
return true;
}
}
}
return false;
}
//Dispatch Event
hypEventDispatcher.prototype.dispatch = function(event){
if(this.events[event]){
var listeners = this.events[event],len = listeners.length;
while(len--){ listeners[len](this); }
}
}
//Create Event Function - Use this as the event factory
function hypCreateEvent(eventName){
hypEventObject.prototype = new hypEventDispatcher();
hypEventObject.prototype.dispatchHypEvent = function(eventName){ this.dispatch(eventName); }
eventObject = new hypEventObject();
function hypEventObject(){ hypEventDispatcher.call(this); }
}

/* ~~~~~~~~~ Example Event ~~~~~~~~~ */

//Create Event
hypCreateEvent('hypevent');

//Add a Listener
eventObject.addEventlistener('hypevent',hypEventHandler);

//Event Handler
function hypEventHandler(){ alert('fired'); }

//Dispatch the event - this can be added anywhere in js or even in html onclick
eventObject.dispatchHypEvent('hypevent');

Detect mouse coordinates

//Mouse Coordinates
window.onload = ezbMouseInit;
function ezbMouseInit(){ document.onmousemove = ezbStoreCoords; }

function ezbStoreCoords(e){
var wrapWidth = ezbGetElementWidth('wrap');
var e = e;
if(e){
var mouseX = e.clientX;
var mouseY = e.clientY;
}
else{
var mouseX = event.clientX;
var mouseY = event.clientY;
}
}

Fader for elements

//Fader
function ezbFade(eid,time){
if(time) fadeTime = time
else fadeTime = 1000.0;
var element = document.getElementById(eid);
if(element == null) return;
if(element.FadeState == null){
if(element.style.opacity == null || element.style.opacity == '' || element.style.opacity == '1') element.FadeState = 2;
else element.FadeState = -2;
}
if(element.FadeState == 1 || element.FadeState == -1){
element.FadeState = element.FadeState == 1 ? -1 : 1;
element.FadeTimeLeft = fadeTime - element.FadeTimeLeft;
}
else{
element.FadeState = element.FadeState == 2 ? -1 : 1;
element.FadeTimeLeft = fadeTime;
setTimeout("ezbAnimateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
}
}

function ezbAnimateFade(lastTick,eid){
var curTick = new Date().getTime();
var elapsedTicks = curTick - lastTick;
var element = document.getElementById(eid);
if(element.FadeTimeLeft <= elapsedTicks){
element.style.opacity = element.FadeState == 1 ? '1' : '0';
element.style.filter = 'alpha(opacity = ' + (element.FadeState == 1 ? '100' : '0') + ')';
element.FadeState = element.FadeState == 1 ? 2 : -2;
return;
}
element.FadeTimeLeft -= elapsedTicks;
var newOpVal = element.FadeTimeLeft/fadeTime;
if(element.FadeState == 1) newOpVal = 1 - newOpVal;
element.style.opacity = newOpVal;
element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
setTimeout("ezbAnimateFade(" + curTick + ",'" + eid + "')", 33);
}

Detect mouse out of browser

function ezbAddEvent(object,oEvent,fnctn){
if(object.addEventListener) object.addEventListener(oEvent,fnctn,false);
else if(object.attachEvent) object.attachEvent("on" + oEvent, fnctn);
}
ezbAddEvent(window,"load",function(e){
ezbAddEvent(document,"mouseout",function(e){
e = e ? e : window.event;
var from = e.relatedTarget || e.toElement;
if(!from || from.nodeName == "HTML") alert('Mouse Left Browser');
});
});