Category: JavaScript

Execute JavaScript files using Rhino

The command to execute a javascript file using rhino. java -jar /path/to/custom_rhino.jar JS_File.js Get Custom Rhino(From Dojo Library)

Install Rhino

Installing Rhino(Javascript interpreter created in java) on Fedora 7 sudo yum install rhino-manual rhino-demo rhino

Scope and Binding in JavaScript

Function x executions in the scope of object y. var Car = function() { this.name = ‘car’; } var Truck…

Find Element’s Position using JavaScript

Find the position of an element using javascript function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) {…

Find the Fourth Sunday

Javascript code for finding the fourth sunday in any given month. function findFourthSunday(year,month) { var fourth_sunday = 0; var sunday_count…

Shortest way to create an XMLHttpRequest object

For best results use a framework – like jx http = window.XMLHttpRequest ? new window.XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject(“MSXML2.XMLHTTP”):…

Object or Array

Find whether the given variable is an object,or is an Array? function isArray(testObject) { return testObject && !(testObject.propertyIsEnumerable(‘length’)) && typeof…