QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Home
  • QIdea
  • QTrack
Home Carbon Ads JavaScript Vibration API with Demo

JavaScript Vibration API with Demo

This post is a part 3 of Advanced JavaScript APIs post series.

Vibration API is mostly available in phones. Its used to vibrate your phone.

window.navigator property exposes a function called as vibrate(). This function take milliseconds as argument and vibrates the phone for that long.

if("vibrate" in window.navigator)
{
   navigator.vibrate(2000);
}
else
{
   console.log("Your browser doesn't support vibration API");
}

Jan 28, 2015Narayan Prusty
Github Style Markdown Editor and PreviewHTML5 Battery Status API with Code Example
Comments: 2
  1. Website design in Oakville
    4 years ago

    Wonderful resourceful information. I actually like what I’ve
    acquired here. You make your site articles easy and
    enjoyable to grasp. a
    I can not wait to learn more from you. Bookmarked!

    ReplyCancel
  2. Eric
    7 years ago

    Hi there,

    I have tested this and it worked on Firefox.

    But it won’t work on Chrome 42 and default android browser. I am using Samsung Note 2.

    Can it work on Chrome for you?

    Thanks.

    ReplyCancel

Leave a Reply to Eric Cancel reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Narayan Prusty

I am a software engineer specialising in Blockchain, DevOps and Go/JavaScript. This is my personal blog where I write about things that I learn and feel interesting to share.

7 years ago 3 Comments Web Development
Share this
0
GooglePlus
0
Facebook
0
Twitter
0
Linkedin
Related Articles
  • Vibrating Phone using Intel XDK
  • Check if CSS property is supported using CSS and JavaScript
  • Passing Objects To addEventListener
  • Changing Text Selection Color Using CSS
  • Generate Unique Number in JavaScript
Our Sponsor
My Books

2014 - 2015 © QNimate
All tutorials MIT license