HTML5 Desktop Notification

I have seen desktop notification on Gmail.When my friends send me any message on Gmail Chat i got a desktop notification.We have only been able to show messages inside the browser using HTML and Javascript But with HTML5 and webkit enabled browsers we can do quite a lot of cool stuff outside the browser.

Check

Check that browser supports Desktop Notification or not.
if (window.web kit Notifications){
 }

Permission

If your browser supports Desktop Notifcation,then user
 permission needed to show the Notification.Ask the user to allow the notification.
//Definition of callback function
function requestingPopupPermission(callback){
  window.webkitNotifications.requestPermission(callback);
}

Name the Function

Then we can give the name of the function to be called
once permission is granted. In this case i am going to do it recursively.
//Definition of callback function
function showPopup(){
  if(window.webkitNotifications.checkPermission() > 0){
   requestingPopupPermission(showPopup);
}
else{
 //Show Popup
}
}

Create Notification

3 parameters are requires to create Notification.
  1. thumb: url of the image to be shown in the notification
  2. title: title of the notification
  3. body: text to show in the notification
var thumb = 'http://wall.shubhamtipstricks.com/
timthumb.php?src=http://wall.shubhamtipstricks
.com/img/stt-lab.png&w=60&h=60';
var title = 'Test Notification';
var body = 'Welcome Here.This is the body of the Notification. ';
 
  
        var popup = window.webkitNotifications.
createNotification(thumb, title, body);

Show/Cancel the Notification

After Creating the Notification Show/Hide it.
//Show the popup
        popup.show();
 
        //set timeout to hide it
        setTimeout(function(){
        popup.cancel();
        }, '10000');

Full HTML And Javascript Code

<HTML>
<HEAD>
<TITLE>Desktop Notification using 
Javascript and Html || Shubham Tips Tricks Demos</TITLE>
</HEAD> 
<BODY>
<a href="#" class="btn" onclick="showPopup();">Notify </a>
<script>
if (window.webkitNotifications){
 
function requestingPopupPermission(callback){
  window.webkitNotifications.requestPermission(callback);
}
 
function showPopup(){
  if(window.webkitNotifications.checkPermission() > 0){
   requestingPopupPermission(showPopup);
}
else{
var thumb = 'http://wall.shubhamtipstricks.com/
timthumb.php?src=http://wall.shubhamtipstricks.
com/img/stt-lab.png&w=60&h=60';
var title = 'Test Notification';
var body = 'Welcome Here.This is the 
body of the Notification.This is the 
body of the Notification.This is the
 body of the Notification.This is the body of the 
Notification.This is the body of the Notification.
This is the body of the Notification.This is the 
body of the Notification. ';
 
  
        var popup = window.webkitNotifications.
createNotification(thumb, title, body);
 
        //Show the popup
        popup.show();
 
        //set timeout to hide it
        setTimeout(function(){
        popup.cancel();
        }, '10000');
 
}
}
</script>
</BODY> 
</HTML>
 

How to use Youtube video as Web Page Background ?

You are probably using static image as background for your webpages but this will be a little more rich experience for you if you could consider placing moving images, like an animation or a self-playing video clip, in the background of your web pages.

I am using YouTube’s IFRAME embed code to embed that video so that it occupies the entire page.Both width and height are set to 100% and the z-index is set to negative so the YouTube video layer will appear several levels below the main content.

To get started,find (Ctrl+F) <body> tag and simply paste the code below the tag. You can replace VIDEO ID with YouTube video ID that you would like to use in the background.
<div style=”position: fixed; z-index: -99; width: 100%; height: 100%”>
<iframe frameborder=”0″ height=”100%” width=”100%”
src=”https://www.youtube.com/embed/VIDEO ID?autoplay=1&controls=0&loop=1&rel=0&showinfo=0&autohide=1&wmode=transparent&hd=1″>
</iframe>
</div>
//Replace the VIDEO ID to actual youtube video id like WGByijP0Leo
 

HTML 5 Application Cache

Are you using  HTML5,then take a look at post to know that how to develop a web offline project using HTML5 Application cache. HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection.With HTML5 it is easy to make an offline version of a web application, by creating a cache manifest file.

There are many advantages of HTML5 Application cache.Such of them are:-

  • Users can use the application when they are offline
  • Page loads faster
  • The browser will only download updated/changed resources from the server
Internet Explorer 10, Firefox, Chrome, Safari and Opera support Application cache.

Example of HTML5 Cache Manifest

<!DOCTYPE HTML>
<html manifest="stt.appcache">

<body>
The content of the document......
</body>

</html>

 Basic Codes of Application Cache

To enable application cache, include the manifest attribute in the document’s <html> tag:
<!DOCTYPE HTML>
<html manifest="<filename>.appcache">
...
</html>

Manifest File Must Contains

The manifest file is a simple text file, which tells the browser what to cache (and what to never cache).
The manifest file has three sections:
  • CACHE MANIFEST - Files listed under this header will be cached after they are downloaded for the first time
  • NETWORK - Files listed under this header require a connection to the server, and will never be cached
  • FALLBACK - Files listed under this header specifies fallback pages if a page is inaccessible
The first line, CACHE MANIFEST, is required:
CACHE MANIFEST
/theme.css
/logo.gif
/main.js
The secong line, NETWORK
NETWORK:
login.php
An asterisk can be used to indicate that all other resources/files require an internet connection:
NETWORK:
*
The third line,FALLBACK
FALLBACK:
offline/offline.html

Basic codes of Cache Manifest File

CACHE MANIFEST
/Shubham-Tips-Tricks.png

NETWORK:
login.php

FALLBACK:
offline/offline.html
 
 

MORE ABOUT DETAIL  

"CLICK HERE"

 

 

0 comments:

Post a Comment

 
  • Symbolic Constants

    What Is The Variables and Arithmetic Expressions The next program uses the formula oC=(5/9)(oF-32) to print the following table

  • Navigation For Blogger New Script

    Today we will see how to add a nice page number navigation hack blogger. The default navigation links (i.e Older Posts) is not the friend

  • How To Creat Facebook Fantasty Box

    Fantasty Look Custom Facebook Like Box To Blogger Facebook Like Box is very useful widget to show visitors the authority and love of t

  • Basic Knowladge Of Computer

    Computer is an electronic device that accepts the data from any Input Device process them according to instruction and gives the Output.Computer is an electronic device that..

  • Earn Money To Easy Way

    HI MEMBER, FIRST OF ALL HEARTY WELCOME TO OUR COMPANY.FIRST TIME IN THE WORLD WE ARE INTRODUCING A STEP BY STEP TRAINING PROCESS TO MAKE MONEYMAKE MONEY ONLINE

Top
Blogger Template - See more at: http://www.arya2014.blogspot.in
ONLINE EDUCATION Basic Computer Application EARN MONEY TO EASY WAY Make Money Online "C" PROGRAMING Introducing "C" Language