Total Pageviews

Tuesday, July 8, 2014

html 5 video tag.

Follow kvn_krishna on Twitter


<video width='320' height='240' controls autoplay>
 <source src='http://someurl/video.mp4' type='video/mp4'>
  <source src='http://someurl/video.ogg' type='video/ogg'>
  <source src='http://someurl/video.webm' type='video/webm'>

<object data='movie.mp4' width='320' height='240'>
<embed width='320' height='240' src='movie.swf'>
</object>
</video>  

Wednesday, November 20, 2013

Add loader until the page loads completely

This code used to show the loader until the page loads.......

var overlay = jQuery('<div id="overlay"> </div>');
overlay.appendTo(document.body)
$(window).load(function() {
 $('#overlay').html("<img src="ajaxLoader.gif" class="ajaxLoader"/>");

});


Follow kvn_krishna on Twitter


Ajax Loader, $.getJSON Loader,

Just copy Paste on ur Script top,

It defines globally so no need add again and again for ajax events. It will fire for the jQuery Ajax events.



var cssOverlayOption = {
"position": "fixed",
    "top": 0,
    "left": 0,
    "width": "100%",
    "height": "100%",
    "background-color": "#000",
    "filter":"alpha(opacity=50)",
    "-moz-opacity":"0.5",
    "-khtml-opacity": "0.5",
    "opacity": "0.5",
    "z-index": 10000
};

var loaderImageCenter = {
"position":"relative",
"top":"50%",
"left":"50%"
};
var overlay = jQuery('<div id="overlay"><img src="images.jpg" id="loaderImage" width="99" height="102" title="Loading..." align="middle"  /> </div>');
overlay.appendTo(document.body);


$(document).ajaxStart(function() {
$("#loaderImage").css(loaderImageCenter);
    $("#overlay").css(cssOverlayOption).show();

});


Follow kvn_krishna on Twitter

Sunday, June 23, 2013

Detect Browser in php, User agent detection in php

function detect_mobile()
{
    if(preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i', $_SERVER['HTTP_USER_AGENT']))
        return true;

    else
        return false;
}

$mobile = detect_mobile();
if($mobile === true)
{

header("location:mobiledevice/index.php");

}
else
{

echo '<h3>you are looking via system browser</h3>';

/*echo $_SERVER['HTTP_USER_AGENT'];*/

}





Follow kvn_krishna on Twitter

Detect Browser in Javascript, User agent detection in Javascript

<script type="text/javascript">
 var ismobile = navigator.userAgent.match(/(alcatel) | (amoi) | (android) | (avantgo) | (blackberry) | (benq) | (cell) | (cricket) | (docomo) | (elaine) | (htc) | (iemobile) | (iPhone) | (ipad) | (ipaq) | (ipod) | (j2me) | (java) | (midp) | (mini) | (mmp) | (mobi) | (motorola) | (nec-) | (nokia) | (palm) | (panasonic) | (philips) | (phone) | (playbook) | (sagem) | (sharp) | (sie-) | (silk) | (smartphone) | (sony) | (symbian) | (t-mobile) | (telus) | (vodafone) | (wap) | (webos) | (wireless) | (xda) | (xoom) | (zte)/i);

 if(ismobile)
 {

// window.location = 'https://www.google.com.my';
 alert("You are using mobile");

 }
 else
 {

 // window.location = 'https://www.yahoo.com';
 alert("You are using system");


 }
</script>


Follow kvn_krishna on Twitter

Detect Browser in htaccess, User agent detection in htaccess

RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://mobiledomin.com [R=301]

Follow kvn_krishna on Twitter

Tuesday, June 4, 2013

Href click submit jQuery, Simple JQuery validation, Form submit and reset jQuery. Self refresh jQuery



How to submit form with anchor tag/ href/a click in jquery?
Reload and Reset form jquery?
Simple validation in Jquery

 // bind "click" event for links with title="submit"
  $("a#submitcontact").click( function(){
    // it submits the form it is contained within
    $(this).parents("#register-form").submit();
  });
 
  $("#register-form").submit(function() {
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//$("#inline").empty().append('abc');
var address = $("input[name=Email]").val();
var emailError = true;
if($("input[name=Nama]").val() == ''){
$("#inline").empty().append('Please enter your Name.');
$('#Nama').focus();
return false;
}

else if($("textarea[name=Alamat]").val() == ''){
 
$("#inline").empty().append(' Please enter your Alamat');
           
$('#Alamat').focus();
return false;
}

else if($("input[name=Email]").val() == ''){
 
$("#inline").empty().append(' Please enter your E-mail address');
           
$('#Email').focus();
return false;
}
else if(!reg.test(address)) {
//emailError = true;
$("#inline").empty().append('Please enter your valid E-mail address.');
$('#Email').focus();
return false;
}
else if($("input[name=NoTelp]").val() == ''){
$("#inline").empty().append('Please enter your NoTelp.');
                 
$('#NoTelp').focus();
return false;
}

else if($("textarea[name=Pesan]").val() == ''){
 
$("#inline").empty().append(' Please enter your Pesan');
           
$('#Pesan').focus();
return false;
}


else{
                    return true;
                }
           
         });


 $("a#reseter").click( function(){
    // it submits the form it is contained within
//opener.location.reload(true);
window.location.href = "contact.html";
   // $(this).closest('form').find("input[type=text], textarea").val("");
   // $(this).parents("#register-form").reset();
  });


 
});



Follow kvn_krishna on Twitter