Jan 12, 2014

script

JavaScript can write directly into the HTML output stream:
You can only use document.write in the HTML output. If you use it after the document has loaded (e.g. in a function), the whole document will be overwritten.

Java script that makes your web site to come alive.




 Java script that makes your web site to come alive!

Allows client-side scripts to

1. Interact with the user

2. Control the browser

3. Communicate asynchronously

4. Alter the document content that is displayed

JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics.

2 ways of writing a function


Examples:

1. Simple

1.1 recursive function
function factorial(n) {

    if (n === 0) {

        return 1;

    }

    return n * factorial(n - 1);

}


2. Anonymous

2.1 Immediately-invoked function expressions:

Allow functions to pass around variables under their own closures.


var v;

v = 1;

var getValue = (function(v) {

  return function() {return v;};

})(v);

v = 2;

getValue(); // 1


2.2 closure example:


var displayClosure = function() {

    var count = 0;

    return function () {

        return ++count;

    };

}

var inc = displayClosure();

inc(); // returns 1

inc(); // returns 2

inc(); // returns 3


2.3  Variadic function


var sum = function() {

    var i, x = 0;

    for (i = 0; i < arguments.length; ++i) {

        x += arguments[i];

    }

    return x;

}

sum(1, 2, 3); // returns 6


 

Jan 9, 2014

The CSS, Essential for your site to look classy.


The CSS, Essential for your site to look classy.  
CSS stands for Cascading Style Sheets. It is mainly developed for separating document content from document codesentation. Document content can be in xml, html, xhtml document. And the style is written in CSS. 

Cascading means giving priorities on the style attribute over different available style attributes based on the priority rules.Web site viewers can use a different style sheet, perhaps one on their own computer, to override the one the author has specified.
Advantages of using CSS
1. Separation of content from presentation
2. Site-wide consistency
3. Bandwidth
4. Page reformatting
5. Accessibility
Three ways of styling the web page.

CSS Priority scheme (highest to lowest)
Priority
CSS Source Type
Description
1
User defined
Most browsers have the accessibility feature: a user defined CSS
2
Inline
A style applied to an HTML element via HTML ‘style’ property
3
Media Type
A property definition applies to all media types, unless a media specific CSS defined
4
Importance
The ‘!important’ value overwrites the previous priority types
5
Selector specificity
A specific contextual selector (#heading p) overwrites generic definition
6
Rule order
Last rule declaration has a higher priority
7
Parent inheritance
If a property is not specified, it is inherited from a parent element
8
CSS property definition in HTML document
CSS rule or CSS inline style overwrites a default browser value
9
Browser default
The lowest priority: browser default value is determined by W3C initial value specifications