Javascript Articles - Page 541 of 671

Playing MP4 video in WebView using HTML5 in Android

Ankith Reddy
Updated on 25-Jun-2020 07:12:13

975 Views

To play MP4 video in WebView, you need to first declare Content Provider in Manifest −Implement open file with open() method −URI myURL = URI.create("file:///mypath/new.mp4"); File f = new File(myURL); ParcelFileDescriptor p =    ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY); return p;

Touchmove pointer-events: none CSS does not work on Chrome for Android 4.4 / ChromeView

Lakshmi Srinivas
Updated on 25-Jun-2020 07:29:12

263 Views

The touchstart event is fired when the touchpoint is positioned on the touch surface. Use addEventListener() for touchmove pointer-events −overlay.addEventListener('touchstart', function(ev){    ev.preventDefault(); });Here, we have also used the preventDefault() method. The preventDefault() method prevents the browser from executing the default action.

How can I make a div with irregular shapes with CSS3 and HTM5?

karthikeya Boyini
Updated on 25-Jun-2020 07:17:00

569 Views

With CSS3, you can always create shapes like rectangle, triangle, etc.Let us see how −The following is a rectangle −#shape1 {    width: 300px;    height: 150px;    background: blue; }The following is a triangle −#shape2 {    width: 0;    height: 0;    border-left: 200px solid transparent;    border-bottom: 200px solid blue; }

Playing a WAV file on iOS Safari

Nancy Den
Updated on 25-Jun-2020 07:13:31

506 Views

To play a WAV file on iOS Safari, add a content-range header.The headers would allow a WAV file to play −Content-Range: bytes XX-XX/XX Content-Type: audio/wav Content-Disposition: attachment; filename = "new.WAV" Content-Length: XXAbove, new.WAV is our WAV file.

Measure text height on an HTML5 canvas element

George John
Updated on 25-Jun-2020 07:12:51

2K+ Views

To get the text height, set the font in pt −context.font="15pt Calibri";Now, get the height like the following −var height = parseInt(context.font.match(/\d+/), 10);Above we have used a match to separate the font size from font face.

How to handle mousedown and mouseup with HTML5 Canvas

Daniol Thomas
Updated on 27-Jan-2020 10:52:11

840 Views

To handle the mousedown and mouseup event with HTML5 Canvas,var mouseDown = false; // for mousedown canvas1.onmousedown = function(event){    dragOffset.x = event.x - mainLayer.trans.x;    dragOffset.y = event.y - mainLayer.trans.y;    mouseDown = true; } // for mouseup canvas1.onmouseup = function(event){    if(mouseDown) mouseClick(eevent    mouseDown = false; }

Why cannot I use iframe absolute positioning to set height/width

Samual Sam
Updated on 25-Jun-2020 07:17:36

498 Views

iFrames are replaced elements and considered different than non-replaced elements. The element is a non-replaced element.To achieve the same result i.e. to set both the left/right or top/bottom in an iframe, use a div as a wrapper with absolute position, top, left, right, bottom.Place your iframe with −width:100% height:100%.

HTML 5 Video Buffering a certain portion of a longer video

Krantik Chavan
Updated on 25-Jun-2020 07:18:36

727 Views

Use the TimeRanges object in HTML to set a series of non-overlapping ranges of time. You can also set the start and stop time.The following are the properties −length − Length of time ranges.start(index) − start time, in secondsend(index) − end time, in secondsHere is the code snippet showing buffering −// displays 12 myAudio.buffered.start(1); // displays 20 myAudio.buffered.end(1);

Detecting HTML click-to-call support in JavaScript

Ankith Reddy
Updated on 25-Jun-2020 07:19:05

247 Views

The tel: protocol is supported by almost every mobile device nowadays. This includes Safari on iOS, Android Browser, Symbian browser, Opera Mini, etc.Add it like this −if (/(HTC825)/i.test(navigator.userAgent)){    $("a[href^='tel:']").each(function(){       this.href = this.href.replace("tel:", "wtai://wp/mc;");    }); }

Chrome input type=“number” CSS styling

Lakshmi Srinivas
Updated on 25-Jun-2020 07:20:05

1K+ Views

To style input type = number, use the following CSS −input[type=number]::-webkit-inner-spin-button {    -webkit-appearance: none; }The above shows without a spinner.To show and style a spinner, useinput[type=number]::-webkit-inner-spin-button {    opacity: 1; }OutputThe above shows the following output −

Advertisements