cookieChoices = {};

Friday, 24 July 2015

Disable link button default action in html

Example:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">

        document.oncontextmenu = defaultactiondisable; // this line is to disable right click on web page

        function defaultactiondisable(event) {
            event = event || window.event;

            if(event.preventDefault)
            {
                event.preventDefault // this is for ie9 and later versions
            }
            else
            {
                event.returnValue = false;  //This is ie8 and earlier versions
            }
        }

    </script>
</head>
<body>
    <h1>This is demo of prevent default action of link button </h1>

    <a href="www.google.com" onclick="defaultactiondisable(event)">Go to Search</a>
</body>
</html>

Disable Browser right click



using oncontextmenu we can disable right click on browser web page.


Example:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body oncontextmenu="return false">
    <h1> This is demo of disable right click in web page</h1>
</body>
</html>

Introduction


Introduction


  • It is Scripting language.
  • make the html web pages dynamic using this.
  • creates  interactivity to html tags.
  • we can embedded the java script in to html tags.
  • open source.
  • light weight programming language.
  • case sensitive.
  • data types: numbers, Boolean and strings.
  • var is the keyword to create any of the data types.
  • dynamically typed language, datatypes are changes automatically.
  • // -- single line comment and /* -------------*/ double line comments.
  • code is placed in between the <script>...........</script> tags.  

Tuesday, 21 July 2015

Working with Images

Class                                           Description 
img-rounded                       Adds rounded corners to an image (not available in IE8)
img-circle                        Shapes the image to a circle (not available in IE8)
img-thumbnail                Shapes the image to a thumbnail & adds a bit of padding and a gray border
img-responsive             Makes an image responsive (will scale nicely to the parent element)
push-left                        To align image towards left of text
push-right                      To align image to right side of text .


Example: 

<div class="row" style="background-color:black">
    <img src="/images/gradient_radial.jpg" class="col-sm-offset-3 col-sm-2 img-rounded">
    <img src="/images/gradient_radial.jpg" class="col-sm-2 img-circle ">
    <img src="/images/gradient_radial.jpg" class="col-sm-2 img-thumbnail">
</div>

Note that the images restore their original size if the width of browser is reduced (smaller resolution devices).

  •  To align image to right / left of paragraph use "pull-right" / "pull left" 
  • To resize Image with change of resolution use "img-responsive" 

<img src="/images/Background.jpg" class="col-sm-4 pull-right img-responsive"> 

This is text around image This is text around image This is text around image This is text around image This is text around image This is text around image This is text around image This is text around image This is text around image This is text around image   

Bootstrap Button

Button can be rendered using one of the following ways:

1. <a class="btn btn-default" href="#" role="button">Link</a>
2. <button class="btn btn-default" type="submit">Button</button>
3. <input class="btn btn-default" type="button" value="Input">
4. <input class="btn btn-default" type="submit" value="Submit">

Its recommended to use <button> over <input> because it ensures matching cross-browser rendering.

Following are the styles we can use for <button>, <input type="button" and <a> tags:

Class                     Description 
btn                      Default/ Standard button.
btn-primary        Provides extra visual weight and identifies the primary action in a set of buttons.
btn-success         Indicates a successful or positive action.
btn-info              Contextual button for informational alert messages.
btn-warning       Indicates caution should be taken with this action.
btn-danger          Indicates a dangerous or potentially negative action.
btn-link             Deemphasize a button by making it look like a link while maintaining button behavior.
btn-sm             Makes a small button
btn-xs              Makes an extra small button
btn-block         Makes a block-level button (spans the full width of the parent element)
active               Makes the button appear pressed
disabled           Makes the button disabled

Examples: 

<button type="button" class="btn btn-default btn-lg">Default Button</button>
 <button type="button" class="btn btn-primary btn-lg ">Primary button</button>
 <button type="button" class="btn btn-link">Button as Link</button>
 <a href="#" class="btn btn-default btn-lg" role="button">Link as Button</a>

 <a href="#" class="btn btn-primary btn-lg" role="button">Link as Primary Button</a> 

Bootstrap Form Layout


  •  Individual form controls automatically receive some global styling. 
  •  All textual <input>, <textarea>, and <select> elements with .form-control are set to width: 100%. 
  • Wrap labels and controls in .form-group for optimum spacing.
  •  Includes support for all HTML5 types: datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.

Bootstrap provides you with following types of form layouts: 
  •  Vertical (default) form.
  •  Inline form.
  •  Horizontal form.

Vertical or basic form 

The basic form structure comes with Bootstrap; individual form controls automatically receive some global styling. 

To create a basic form do the following:
  •   Add a role form to the parent <form> element. 
  •  Wrap labels and controls in a <div> with class .form-group. This is needed for optimum spacing. 
  •  Add a class of .form-control to all textual <input>, <textarea>, and <select> elements.
<form role="form"> 
     <div class="form-group"> 
         <label for="email">Email address:</label> 
         <input type="email" class="form-control" id="email"> 
     </div> 
     <div class="form-group"> 
         <label for="pwd">Password:</label> 
         <input type="password" class="form-control" id="pwd"> 
     </div> 
     <div class="checkbox"> 
         <label><input type="checkbox"> Remember me</label> 
     </div> 
     <button type="submit" class="btn btn-default">Submit</button> 
 </form>  

In-line Form:

  • Makes a <form> left-aligned with inline-block controls. 
  • This only applies to forms within viewports that are at least 768px wide.
  •  In the above example, add the attribute class="form-inline". 
<form role="form" class="form-inline">

Note:  
  •  Inputs, selects, and textareas are 100% wide by default in Bootstrap. To use the inline form, you'll have to set 
    a width on the form controls used within. 
  •  Screen readers will have trouble with your forms if you don't include a label for every input. For these inline 
    forms, you can hide the labels using the .sr-only class. 
<form class="form-inline" role="form"> 
    <div class="form-group"> 
        <label class="sr-only" for="email2">Email address</label> 
        <input type="email" class="form-control" style="width:200px" id="email2" placeholder="Enter email"> 
    </div> 
    <div class="form-group"> 
        <label class="sr-only" for="password1">Password</label> 
        <input type="password" class="form-control" id="password1" placeholder="Password"> 
    </div> 
    <div class="checkbox"> 
        <label> 
            <input type="checkbox"> Remember me 
        </label> 
    </div> 
    <button type="submit" class="btn btn-default">Sign in</button> 
</form>  

Horizontal Form: We can use Bootstrap's predefined grid classes to Aligns labels and groups of form controls in a horizontal layout. 
Note: The class .form-groups behaves as grid rows, so no need for .row. 

<form class="form-horizontal" role="form"> 
     <div class="form-group"> 
         <label class="control-label col-sm-2" for="email">Email:</label> 
         <div class="col-sm-10"> 
             <input type="email" class="form-control" id="email" placeholder="Enter email"> 
         </div> 
     </div> 
     <div class="form-group"> 
         <label class="control-label col-sm-2" for="pwd">Password:</label> 
         <div class="col-sm-10"> 
  <input type="password" class="form-control" id="pwd" placeholder="Enter password"> 
         </div> 
     </div> 
     <div class="form-group"> 
         <div class="col-sm-offset-2 col-sm-10"> 
             <div class="checkbox"> 
                 <label><input type="checkbox"> Remember me</label> 
             </div> 
         </div> 
     </div> 
     <div class="form-group"> 
         <div class="col-sm-offset-2 col-sm-10"> 
             <button type="submit" class="btn btn-default">Submit</button> 
         </div> 
     </div> 
 </form>  

Rendering of Checkbox and Radio 

By default all checkbox and radio buttons are rendered vertical.  
To show them in-line use the attribute: checkbox-inline or radio-inline 

<form class="form-horizontal" role="form"> 
    <div class="checkbox"> 
        <label><input type="checkbox" value="">Option 1</label> 
    </div> 
    <div class="checkbox disabled"> 
        <label><input type="checkbox" value="">Option 2</label> 
    </div> 
    <div class="checkbox"> 
        <label><input type="checkbox" value="">Option 3</label> 
    </div> 
    <div> 
        <label class="checkbox-inline"> 
            <input type="checkbox" id="inlineCheckbox1" value="option1"> Option 1 
        </label> 
        <label class="checkbox-inline"> 
<input type="checkbox" id="inlineCheckbox2" value="option2"> Option 2 
        </label> 
        <label class="checkbox-inline"> 
            <input type="checkbox" id="inlineCheckbox3" value="option3"> Option 3 
        </label> 
    </div> 
</form>  

Use the class .form-control-static on a <p>, when you need to place plain text next to a form label within a 
horizontal form. 

<label class="col-sm-2 control-label">Email</label> 
<div class="col-sm-10"> 
    <p class="form-control-static">email@example.com</p> 
</div> 

Validation States: 

To use, simply add the appropriate class (.has-warning, .has-error, or .has-success) to the parent element

<div class="form-group has-success"> 
    <label for="inputSuccess"> 
        Input with success 
    </label> 
    <div> 
        <input type="text" class="form-control" id="inputSuccess"> 
    </div> 
</div>  

Disabled inputs and fieldsets: 

<form role="form"> 
    <fieldset disabled > 
        <div class="form-group"> 
            <label for="t1">Disabled input</label> 
            <input type="text" id="t1" class="form-control" placeholder="Disabled input"> 
        </div> 
        <div class="form-group"> 
            <label for="s1">Disabled select menu</label> 
 <select id="s1" class="form-control"> 
                <option>Disabled select</option> 
            </select> 
        </div> 
        <div class="checkbox"> 
            <label> 
                <input type="checkbox"> Can't check this 
            </label> 
        </div> 
        <button type="submit" class="btn btn-primary">Submit</button> 
    </fieldset> 
</form>

Control Height Sizing: Set heights using classes like .input-lg 

<form role="form"> 
     <input class="form-control input-lg" type="text" placeholder=".input-lg"> 
     <input class="form-control" type="text" placeholder="Default input"> 
     <input class="form-control input-sm" type="text" placeholder=".input-sm"> 
 </form>  

Control Width Sizing: set widths using grid column classes like .col-sm-*. 

<form role="form" class="form-horizontal"> 
    <div class="row"> 
        <div class="col-sm-2"> 
            <input type="text" class="form-control" placeholder=".col-sm-2"> 
        </div> 
        <div class="col-sm-3"> 
            <input type="text" class="form-control" placeholder=".col-sm-3"> 
        </div> 
        <div class="col-sm-4"> 
            <input type="text" class="form-control" placeholder=".col-sm-4"> 
        </div> 
    </div> 
</form>  




Bootstrap Tables

<table> classes: 

Class                Description 
table Adds      basic styling (light padding and only horizontal dividers) to any <table>
table-striped   Adds alternate row style (not available in IE8)
table-bordered Adds border on all sides of the table and cells

table-hover     Enables a hover state on table rows within <tbody>
table-condensed Makes table more compact by cutting cell padding in half
table-responsive Makes the table responsive to different resolution

<table class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th>#</th>
            <th>Name</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>John</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Ravi</td>
        </tr>
        <tr>
            <td>3</td>
            <td>Srinivas</td>
        </tr>
    </tbody>
</table>

<tr>, <th> and <td> Contextual Classes 
Use the classes below to color table rows or cells:

Class            Description 
active           Applies the hover color to a particular row or cell
success         Indicates a successful or positive action
info               Indicates a neutral informative change or action
warning         Indicates a warning that might need attention
danger          Indicates a dangerous or potentially negative action

Responsive Tables: 

By wrapping any .table in .table-responsive class, you will make the table scroll horizontally up to small devices
(under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.


<div class="table-responsive">
     <table class="table">
         <caption>Responsive Table Layout</caption>
         <thead>
             <tr>
                 <th>Product</th>
                 <th>Payment Date</th>
                 <th>Status</th>
             </tr>
         </thead>
         <tbody>
             <tr>
                 <td>Product1</td>
                 <td>23/11/2013</td>
                 <td>Pending</td>
             </tr>
             <tr>
                 <td>Product2</td>
                 <td>10/11/2013</td>
                 <td> Delivered Delivered Delivered Delivered Delivered Delivered Delivered Delivered Delivered
Delivered Delivered Delivered Delivered Delivered Delivered Delivered Delivered Delivered Delivered Delivered
Delivered Delivered Delivered Delivered Delivered Delivered Delivered </td>
             </tr>
         </tbody>
     </table>
 </div>