Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Sunday, 9 February 2014

Components of Browser

Components of Browser 

Browser layout engine - The browser’s layout engine goes through the HTML and CSS to build a “document” using the HTML Document Object Model (DOM).

 


Browser viewport - The browser displays a rendered page in thebrowser’s viewport.
JS interpreter - The JS interpreter references the DOM to make changes to the web page without needing to reload it.

How web pages works - jQuery

How web pages works?

1.   The browser requests a web page from a server when someone types a web address into the browser’s URL bar.
2.    The server finds the requested file(s) and sends them to the browser
3.    The browser displays a rendered HTML page based on the file sent from the server.



The power of script

To change your web pages on the fly, with an HTML tag known as <script>


Role of jQuery (and JavaScript)

Every browser comes with a built-in JavaScript interpreter that takes the directions you write in between the <script>tags and translates those directions into different kinds of action on the web page.
jQuery is a JavaScript library specialized for changing web page documents on the fly.

 

What is jQuery?

What is JavaScript?

JavaScript is a scripting language that was designed for use within a web browser. Typically, JavaScript is used for interface interactions. Slideshows and other interactive components are typically done using JavaScript.

What is jQuery?

jQuery is a lightweight, "write less, do more", JavaScript library.
jQuery is an open source, cross-browser, CSS3 compliant JavaScript library that has made client side scripting relatively easier. It can produce dynamic web pages as well as Flash-like animations. jQuery today powers over 55% of the 10,000 most visited websites on the internet.
jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.
The jQuery library contains the following features:
       HTML/DOM manipulation
       CSS manipulation
       HTML event methods
       Effects and animations
       AJAX
       Utilities

 

Why jQuery?

  1. It comes with MIT License (http://opensource.org/licenses/MIT) and is open source.
  2. Cross-browser Compatibility  
  3. Fast & Small Footprint
  4. Short Learning curve & Great Documentation (http://docs.jquery.com)
  5. Tons of Plugins and Helpful Utilities(jQuery UI)
  6. CSS3 Selectors Compliant
  7. Widespread Adoption
  8. Bugs free or fixed pretty quick

Why not jQuery?

       jQuery is easy to accomplish, but not always easy to implement as compared to, say, CSS.
       Even though it is swift, the end product may not always be fast-paced.
       You just have to get the version correct, and pray that you keep getting it correct.
       If improperly used as a framework, things can get complicated beyond measure.

Tuesday, 21 January 2014

Dynamically add button, textbox, input, radio elements in html form using JavaScript

Adding Elements like textbox, button, radio button etc in a html form using JavaScript is very simple. JavaScript’s document object has a method called createElement() which can be used to create html elements dynamically.
We had used this function in our tutorial: Dynamic combobox-listbox-drop-down using javascript to add dynamic options to a combo box-listbox. Let us use this function to create textboxes, radio buttons, buttons etc dynamically and add them in our page.

Following is the source code of our example.
<HTML>
<HEAD>
<TITLE>Dynamically add Textbox, Radio, Button in html Form using JavaScript</TITLE>
<SCRIPT language="javascript">
function add(type) {
    //Create an input type dynamically.
    var element = document.createElement("input");
    //Assign different attributes to the element.
    element.setAttribute("type", type);
    element.setAttribute("value", type);
    element.setAttribute("name", type);
    var foo = document.getElementById("fooBar");
    //Append the element in page (in span).
    foo.appendChild(element);
}
</SCRIPT>
</HEAD>
<BODY>
<FORM>
<H2>Dynamically add element in form.</H2>
Select the element and hit Add to add it in form.
<BR/>
<SELECT name="element">
    <OPTION value="button">Button</OPTION>
    <OPTION value="text">Textbox</OPTION>
    <OPTION value="radio">Radio</OPTION>
</SELECT>
<INPUT type="button" value="Add" onclick="add(document.forms[0].element.value)"/>
<span id="fooBar">&nbsp;</span>
</FORM>
</BODY>
</HTML>
Also note that we have used setAttribute() method to assign the attributes to our dynamically created element. 

Demo: CODE-PEN