Thursday, February 21, 2013

some Links javascirpt op

how javascipt came into pic
http://www.pcmag.com/article2/0,2817,1554984,00.asp

how to optimize

https://developers.google.com/speed/docs/best-practices/payload?hl=en

Wednesday, October 19, 2011

To find elements , no of elemtents .

document.write(document.anchors.length); // find all anchors on page
if yo have more than 2 forms
document.write(document.forms[0].name); // for first form name
document.write(document.images.length);// all images
document.write(document.cookie);// find cookies
 var x=document.getElementsByName("x");
  alert(x.length);// find no of elements on a page
getElementById() Accesses the first element with the specified id
getElementsByName() Accesses all elements with a specified name
getElementsByTagName() Accesses all elements with a specified tagname

javascritp style to elemnt

document.body.style.backgroundColor="lavender";

find a tag : document.getEelementByTagName

x=document.getElementsByTagName("p");

for (i=0;i<x.length;i++)
{
document.write(x[i].innerHTML);
document.write("<br />");
}

Objects in advance

objName.propName
objName.methodName()

Arrays

The following code creates an Array object called myCars:
1:
var myCars=new Array(); // regular array (add an optional integer
myCars[0]="Saab";       // argument to control array's size)
myCars[1]="Volvo";
myCars[2]="BMW";
2:
var myCars=new Array("Saab","Volvo","BMW"); // condensed array
3:
var myCars=["Saab","Volvo","BMW"]; // literal array
Note: If you specify numbers or true/false values inside the array then the variable type will be Number or Boolean, instead of String.

CREATING OBJECTS

var today = new Date()
var d1 = new Date("October 13, 1975 11:13:00")
var d2 = new Date(79,5,24)
var d3 = new Date(79,5,24,11,33,0)


If you have a function like date and want to give diffrent pararameters depending on conditions then use
can create a object with a new key word and store it in a variable and keep assignig it different parameters