For smart Primates & ROBOTS (oh and ALIENS ).

Showing posts with label html5. Show all posts
Showing posts with label html5. Show all posts

Thursday, January 12, 2017

load images using JavaScript

Another way to load images using JavaScript

When you write code in JavaScriputer system.
Below is the another way to load images from JavaScript code.

<img src="data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-src="http://www.mysite.com/media/t1.png">
 
function initS() {
    var myimg = document.getElementsByTagName('img');
    for (var i=0; i<myimg.length; i++) {
        if(myimg[i].getAttribute('data-src')) {
            myimg[i].setAttribute('src',myimg[i].getAttribute('data-src'));
        }
    }
}
setTimeout("initS();", 20000);
</script> 



connect On of OFF.
Share:

Saturday, January 07, 2017

Load mp4 file

How to load .mp4


below is few lines of code:

<video width="640" height="480" controls>
  <source src="4.mp4" type="video/mp4">
   Your browser does not support the video tag.
</video>




Share:

Another way to load JavaScript


Another way to load JavaScript

There are another way to load Javascript file in any page. use below code to load Js file.

<script type="text/javascript">
function dhtml5() {
var eh= document.createElement("script");
eh.src = "a1.js";
document.body.appendChild(eh);
}
setTimeout("dhtml5();",8000);
</script>


Share:

Tuesday, May 31, 2016

How to check if internet active in your computer

How to check if internet active in your computer

When you write code in JavaScript sometime you code does not execute due to loss of internet connectivity.  so how you check if internet connection properly ON in your computer system.
below is one line of JavaScript code that check your system internet connect On of OFF.

Code is:
var isonline = navigator.onLine;
Share:

Tuesday, April 19, 2016

how to fix Configure the viewport

How to fix Configure the viewport

Sometime when you increase score of your site in Google PageSpeed Insights for SEO purpose and optimize it's responsiveness you can face the issue Configure the viewport. It is simple to fix the Configure the viewport issue. use only this below meta tag. if you have already this similar meta tag with extra aruments then just delete that one and use below code.

Tag is:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Share:

Thursday, May 28, 2015

How to fix any HTML tag at any position

Problem:

How to fix any HTML tag at any position for ex: fix a div at right bottom corner?

Solution:

Use style z-index, bottom, right attribute

Example:

<div id="loading_msg" style="position: fixed; z-index: 99;  bottom: 15px; right: 10px;
    display:; background-color:#CC99FF">Loading now Please wait...</div>
Share:

Thursday, April 23, 2015

html html5 to Pdf

Generate PDF file of html html5 with div span tags. It really works on liquid layout also!
Try it now!





html html5 to Pdf
Download here:

Part-1 
Part-2
Part-3
Part-4
Part-5
Part-6
Part-7
Part-8
Part-9
Part-10
Part-11

Extract  all files Part-1 to Part-11 and paste all files in one folder and double click on
Html-Html5-to-PDF.exe
Share:

Friday, April 17, 2015

jquery ui datepicker automatically delete text from input field

Problem:

Did you worked with jquery ui date picker? when assigned a default value to text filed, jquery ui datepicker will automatically delete text from that textbox field. So how to stop it?

Solution:

It seems the bug in jquery ui datepicker which is automatically delete text from input field. to overcome this problem you need to write 22 lines of code as example below:

Example:

// assume that the $edit_diesel_date is already filled with date value.
// write this code very bootom of your page.
function dook() {  $("#diesel_date").val("<?php echo $edit_diesel_date;?>");     }
setTimeout("dook();", 500);
Share:

Wednesday, March 18, 2015

Change Search in This Blog size

Problem:

If you have a blog owner in blogger and used the "Search in This Blog" widget, you can see this size is very large and taking lot of spaces in your blog

Solution:



Use below code at the end of your blogger XML file

<script>
function r_search() {
var r_place_s=&quot;h2&quot;;
var r_place_t=&quot;h5&quot;;
var Attribution1=document.getElementById(&quot;CustomSearch1&quot;);
var Attribution1_html=Attribution1.innerHTML;
var regex = new RegExp( &#39;(&#39; + r_place_s + &#39;)&#39;, &#39;gi&#39; );
Attribution1.innerHTML=Attribution1_html.replace( regex, r_place_t );
}
r_search();
</script>

Share:

Friday, March 13, 2015

Gauge chart in Google Chart

How to implement Google Gauge chart. The most important things is that how to change it's needle alternate with some interval. I have made the code that will change Gauge Google Chart's needle alternate interval.


Gauge chart in Google Chart











EXAMPLE - 1
--------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
How to use Gauge chart and how to change needle frequently interval.
if this code is now show the chart then remove above two lines of <!DOCTYPE tag and <html tag and use listed below tags:
1- <html>  2- <head>
-->
  <head>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
      google.load('visualization', '1', {packages: ['gauge']});
    </script>
    <script type="text/javascript">
    var gauge;
    var gaugeData;
    var gaugeOptions;
    function drawGauge() {
      gaugeData = google.visualization.arrayToDataTable([['Engine', 'Torpedo'], [120, 80]]);
      gauge = new google.visualization.Gauge(document.getElementById('gauge'));
      gaugeOptions = {
          min: 0,
          max: 280,
          yellowFrom: 200,
          yellowTo: 250,
          redFrom: 250,
          redTo: 280,
          minorTicks: 5
      };
      gauge.draw(gaugeData, gaugeOptions);
    }
      function changeTemp(dir) {
        //gaugeData.setValue(0, 0, gaugeData.getValue(0, 0) + dir * 25);
      //gaugeData.setValue(0, 1, gaugeData.getValue(0, 1) + dir * 20);
      gaugeData.setValue(0, 0, Math.floor((Math.random()*100)+1));
      gaugeData.setValue(0, 1, Math.floor((Math.random()*100)+1));
      gauge.draw(gaugeData, gaugeOptions);
    }
      setInterval("changeTemp(1);",1000);
    google.setOnLoadCallback(drawGauge);
    </script>
  </head>
  <body style="font-family: Arial;border: 0 none;">
    <div id="gauge" style="width: 300px; height: 300px;"></div>
  </body>

</html>



EXAMPLE - 2

--------------------
<html>
  <head>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
      google.load('visualization', '1', {packages:['gauge']});
      google.setOnLoadCallback(drawChart);
    
      function drawChart() {
      setInterval("docharts();",4000);
      }

 function docharts(){
var data = google.visualization.arrayToDataTable([
          ['Label', 'Value'],
          ['Memory', Math.floor((Math.random()*100)+1) ],
          ['CPU', Math.floor((Math.random()*100)+1) ],
          ['Network', Math.floor((Math.random()*100)+1)]
        ]);

        var options = {
          width: 400, height: 120,
          redFrom: 90, redTo: 100,
          yellowFrom:75, yellowTo: 90,
          minorTicks: 5,
 animation:{
        duration: 5000
      }
        };
        var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
        chart.draw(data, options);
 }
    </script>
  </head>
  <body>
    <div id='chart_div'></div>
  </body>

</html>
Share:

Wednesday, March 11, 2015

HOW TO REMOVE BLOGGER WORD IN BLOG

Problem:

If you have a blog in blogger. then you can see "blogger" word at the bottom of page or any where in the blog. if you don't need this then how can you remove this?

Solution:

You just need copy and past listed below code at the end of blog.

Example:

<script type='text/javascript'>
function r_p() {
var r_place_s=&quot;Blogger&quot;;
var r_place_t=&quot;Galaxy Code&quot;;
var Attribution1=document.getElementById(&quot;Attribution1&quot;);
var Attribution1_html=Attribution1.innerHTML;
var regex = new RegExp( &#39;(&#39; + r_place_s + &#39;)&#39;, &#39;gi&#39; );
Attribution1.innerHTML=Attribution1_html.replace( regex, r_place_t );
}
Share:

Sunday, September 21, 2014

Thin border table in html

How to create Thin border table in html:
Use following html code to create Thin border table in html.


<table cellspacing="0" cellpadding="1" style="border-color:Black;border-width:1px;border-style:Solid;height:108px;width:100%;border-collapse:collapse;" rules="all" >
  <tbody>
    <tr >
      <th scope="col">Date</th>
      <th scope="col">Time</th>
      <th scope="col">Status at</th>
      <th scope="col">Status</th>
    </tr>
    <tr>
      <td align="center">25/08/2014</td>
      <td align="center">10:20:15</td>
      <td align="left">Status A</td>
      <td align="left">Status B</td>
    </tr>
  </tbody>
</table>

Share:

Thursday, August 14, 2014

Rotate any Div in jquery

Rotate any Div in html jquery.
==========================



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Multirotation test</title>
        <script type="text/javascript" src="../js/jquery-1.6.js"></script>
        <script type="text/javascript" src="jquery.multirotation-1.0.js"></script>
    </head>
    <style type="text/css">
        div{text-align:center;margin:auto}
        div.rotable{background:#00CC66;border:solid 2px #f00;color:#fff;width:10px;height:10px;padding:5px;margin-top:60px;margin-bottom:60px}
    </style>
    <body>
        <div><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
           <div id="img_test" class="rotable">Amit
               
            </div>
            <p id="degs"></p>
        </div>
    </body>
      <script type="text/javascript">
        function plus(id) {
            $(id).rotate({ angle: 10 });
            get(id);
            return false;
        }

        function minus(id) {
            $(id).rotate({ angle: 90, direction: false });
            get(id);
            return false;
        }

        function reset(id) {
            $(id).clearRotation();
            get(id);
            return false;
        }

        function get(id) {
            var degs = $(id).getCurrentDegrees();
            //$('p#degs').html("Current degs: <b>" + degs + "°</b>");
        }
        var ang=1;
        intervalID=setInterval("setRotate('#img_test');",100);
       
        function setRotate(id) {
            $(id).rotate({ angle: 5 });
            get(id);
        }
       
       
    </script>
</html>



HERE IS THE jquery.multirotation-1.0.js CODE:
-----------------------------------------------------------------------

(function($){
    //global array to save the current rotation of the elements
    $.elems_rotation_history = [];

    $.fn.extend({
        clearRotation: function() {
            return this.each(function() {
                //get the element's identifier
                var id = this.id;
                //remove element from array
                $.elems_rotation_history[id] = null;
            });
        },

        getCurrentDegrees: function() {
            var id = this.attr('id');
            if (!$.elems_rotation_history[id]) {
                return 0;
            }
            return degs = $.elems_rotation_history[id].rotation;
        },

        rotate: function(options) {
            //create console
            if (!window.console) console = {};
            console.log = console.log || function(){};
            console.warn = console.warn || function(){};
            console.error = console.error || function(){};

            //set the default values
            var defaults = {
                  angle: 0
                , direction: true
                , speed: 0
                , deg2radians: Math.PI * 2 / 360
                ///debug
                , debug: false
                ///end
            };

            //to access options values use this: options.option_name
            var options = $.extend(defaults, options);

            return this.each(function() {
                //get the element's identifier
                var id = this.id;

                //if there aren't elements and there isn't the element into the array, sets rotation to 0
                if ($.elems_rotation_history && !$.elems_rotation_history[id]) {
                    $.elems_rotation_history[id] = { rotation: 0 };
                }

                //sets the rotation direction
                if (!options.direction) {
                    options.angle = options.angle * (-1);
                }

                //increments angle rotation of the element
                $.elems_rotation_history[id].rotation = (parseInt($.elems_rotation_history[id].rotation) + options.angle) % 360;

                ///debug
                if (options.debug) {
                    console.log("Angle = " + $.elems_rotation_history[id].rotation + " degree");
                }
                ///end

                rad = $.elems_rotation_history[id].rotation * options.deg2radians;
                costheta = Math.cos(rad);
                sintheta = Math.sin(rad);

                var a = parseFloat(costheta).toFixed(8);
                var b = parseFloat(sintheta).toFixed(8);
                var c = parseFloat(-sintheta).toFixed(8);
                var d = parseFloat(costheta).toFixed(8);

                var sMatrix = "matrix(" + a + ", " + b + ", " + c + ", " + d + ", 0, 0)";

                if ($(this).get(0).filters) {
                    if (options.speed > 0) {
                        console.warn("You set the speed options but IE doesn't support CSS3 transitions");
                    }

                    //if the browser is IE
                    try {
                        var x = $(this).get(0).filters.item("DXImageTransform.Microsoft.Matrix").enabled;
                    }
                    catch(e) {
                        $(this).get(0).style.filter += "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand');";
                    }

                    var matrix = $(this).get(0).filters.item("DXImageTransform.Microsoft.Matrix");
                    matrix.M11 = costheta;
                    matrix.M21 = sintheta;
                    matrix.M12 = -sintheta;
                    matrix.M22 = costheta;
                    matrix.enabled = true;

                    ///debug
                    if (options.debug) {
                        console.log("Set transform = matrix[" + matrix.M11 + ", " + matrix.M21 + ", " + matrix.M12 + ", " + matrix.M22 + "]");
                    }
                    ///end
                } else {
                    //animate rotation if speed > 0s
                    if (options.speed > 0) {
                        $(this).css("-moz-transition", "all " + options.speed + "s ease-in-out");
                        $(this).css("-webkit-transition", "all " + options.speed + "s ease-in-out");
                        $(this).css("-o-transition", "all " + options.speed + "s ease-in-out");
                    }
                    $(this).css("-moz-transform", sMatrix);
                    $(this).css("-webkit-transform", sMatrix);
                    $(this).css("-o-transform", sMatrix);

                    ///debug
                    if (options.debug) {
                        console.log("Set transform = " + sMatrix);
                    }
                    ///end
                }
            });
        }
    });
})(jQuery)

Share:

Friday, July 11, 2014

Add html tag dynamically in html

Add html tag dynamically in html

<script src="jquery-2.1.1.js" language="javascript" type="application/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var ID = 1;
        function addRow() {
            var html =  '<tr>' +
                        '<td>Name: <input type="text" name="aa' + ID + '" /></td>' +
                        '<td>File: <input type="file" name="fileUpload' + ID + '" /></td>' +
                        '<td><input type="button" class="BtnPlus" value="+" /></td>' +
                        '<td><input type="button" class="BtnMinus" value="-" /></td>' +
                        '</tr>'
            $(html).appendTo($("#Table1"))
            ID++;
        };
        $("#Table1").on("click", ".BtnPlus", addRow);
        function deleteRow() {
            if(ID==1) return;
            var par = $(this).parent().parent();
            par.remove();
            ID--;
        };
        $("#Table1").on("click", ".BtnMinus", deleteRow);
    });
</script>
<table id="Table1" cellspacing="3">
    <tr>
        <td>Name: <input type="text" name="aa0"  id="aa0" /></td>
        <td>File: <input type="file" name="fileUpload0"/></td>
        <td><input type="button" class="BtnPlus" value="+" /></td>
        <td><input type="button" class="BtnMinus" value="-" /></td>
    </tr>
</table>
Share:

Display content with delay in jquery

Display content with delay in jquery

Some time you want to show some data with delay, then use the listed below code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Display content with delay</title>
<style>
.my-class {
    display: none;
}
</style>
<script language="javascript" src="jquery-1.10.2.js" type="text/javascript"></script>
</head>
<body>
<div class="my-class">
  <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
  <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
  <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
  <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
  <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
  <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
</div>
</body>
<script>
$(document).ready(function() {
$('.my-class').delay(1000).fadeIn(3500);
});
</script>
</html>
Share:

Fieldset in html

Fieldset example in html
----------------------------
Fieldset is very useful to combine the more than one information which you want to show or
feed data entry. actually it will block the more than one columns (all colums will be shown in one
box with header heading).

<fieldset style="text-align:right; width:300px;" accesskey="c">
<legend><b>Address Details</b></legend>
Name <input type="text" size="50" /><br>
Address <input type="text" /><br>
City <input type="text" /><br>
State <input type="text" />
</fieldset>
Share:

Saturday, July 05, 2014

Image rotate in jQuery

Image rotate in jQuery


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<img style="transform: rotate(285.4deg);" id="myimg"  src="WOW.jpg">
<script type="text/javascript">
    jQuery(function($) {
        $(document).ready(function() {
            window.imagerotate = function () {
                $('#myimg').rotate({
                                angle:0,
                                animateTo:-360,
                                callback: imagerotate,
                                //t: current time,b: beginning value,c: change in value,d: duration
                                easing: function (x,t,b,c,d) {
                                    return c*(t/d)+b+10000;
                                }
                            });
                        };
                        setTimeout('imagerotate()', 1000);
                });
});
</script>
</body></html>          
Share:

Wednesday, May 07, 2014

Zoom in out in html5 Canvas


This is the part of HTML5 Animation. if you want to ZOOM IN and ZOOM OUT in some intervals continuously. then you can use HTML5 canvas. Listed below the code that will ZOOM IN and ZOOM OUT to any image which you want.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="js/jquery-2.1.1.js"></script>
</head>
<body onLoad="drawCanvas();">
    <div>
        <canvas id="myCanvas" width="634" height="378">
            <p>Your browser doesn't support canvas.</p>
        </canvas>
    </div>
</body>
<script>
var surface; var happy; var x = 50; var y = 50; var scale = 0; var scaleDirection = 0.2;
function drawCanvas() {
    surface = document.getElementById("myCanvas");
    if (surface.getContext) {
        happy = new Image();
        happy.onload = loadingComplete;
        happy.src = "Voayger_voyageofdiscovery.jpg";
    }
}
function loadingComplete(e) {
    setInterval(loop, 125);
}
function loop() {
    var surfaceContext = surface.getContext('2d');
    surfaceContext.fillStyle = "rgb(255,255,255)";
    surfaceContext.fillRect(0, 0, surface.width, surface.height);
    // Save the current context
    surfaceContext.save();
    // Translate to the center point of our image
    surfaceContext.translate(x + happy.width * 0.5, y + happy.height * 0.5);
    // Perform the scale
    surfaceContext.scale(scale, scale);
    // Translate back to the top left of our image
    surfaceContext.translate(-happy.width * 0.5, -happy.height * 0.5);
    // Finally we draw the image
    surfaceContext.drawImage(happy, 0, 0);
    // And restore the context ready for the next loop
    surfaceContext.restore();
    // Animate our scale value
    scale += scaleDirection;
    if (scale < 0.2 || scale > 2) {
        scaleDirection = -scaleDirection;
    }
}
</script>
</body>
</html>
 



Share:

Ads Inside Post

Powered by Blogger.

Archive