What is getContext in HTML5 Canvas

Lakshmi Srinivas
Updated on 28-Jan-2020 08:30:13

1K+ Views

The canvas element has a DOM method called getContext, used to obtain the rendering context and its drawing functions. This function takes one parameter, the type of context 2d.Following is the code to get required context along with a check if your browser supports element:var canvas = document.getElementById("mycanvas"); if (canvas.getContext){    var ctx = canvas.getContext('2d');    // drawing code here    } else {    // canvas-unsupported code here }

Strange Cursor Placement in Modal with Autofocus in Internet Explorer

Samual Sam
Updated on 28-Jan-2020 08:29:35

150 Views

To solve this problem, use the following:.modal.fade {    transition:opacity .3s linear; }You can also solve it by forcing the modal to fade in without sliding.windowClass: 'modal fade in'

Cancel Ongoing watchPosition Call in HTML5

Nitya Raut
Updated on 28-Jan-2020 08:28:19

295 Views

The clearWatch method cancels an ongoing watchPosition call. When canceled, the watchPosition call stops retrieving updates about the current geographic location of the device.                    var watchID;          var geoLoc;          function showLocation(position) {             var latitude = position.coords.latitude;             var longitude = position.coords.longitude;             alert("Latitude : " + latitude + " Longitude: " + longitude);          }          function errorHandler(err) ... Read More

Error Codes in the PositionError Object - HTML5 Geolocation

karthikeya Boyini
Updated on 28-Jan-2020 08:27:49

437 Views

The following table describes the possible error codes returned in the PositionError object:CodeConstantDescription0UNKNOWN_ERRORThe method failed to retrieve the location of the device due to an unknown error.1PERMISSION_DENIEDThe method failed to retrieve the location of the device because the application does not have permission to use the Location Service.2POSITION_UNAVAILABLEThe location of the device could not be determined.3TIMEOUTThe method was unable to retrieve the location information within the specified maximum timeout interval.Following is a sample code, which makes use of the PositionError object. Here errorHandler method is a callback method:function errorHandler( err ) {    if (err.code == 1) {     ... Read More

Find Common Elements in Three Sorted Arrays

Samual Sam
Updated on 28-Jan-2020 08:13:58

360 Views

Firstly, initialize three sorted arrays −int []one = {20, 35, 57, 70}; int []two = {9, 35, 57, 70, 92}; int []three = {25, 35, 55, 57, 67, 70};To find common elements in the three-sorted arrays, iterate through the arrays using a while loop and check the first array with a second and second array with the third −while (i < one.Length && j < two.Length && k < three.Length) {    if (one[i] == two[j] && two[j] == three[k]) {       Console.Write(one[i] + " ");       i++;j++;k++;    }    else if (one[i] < two[j]) ... Read More

Delete Web Storage

karthikeya Boyini
Updated on 28-Jan-2020 08:11:29

315 Views

Storing sensitive data on local machine could be dangerous and could leave a security hole. The Session Storage Data would be deleted by the browser immediately after the session gets terminated.To clear a local storage setting you would need to call localStorage.remove('key'); where 'key' is the key to the value you want to remove. If you want to clear all settings, you need to call localStorage.clear() method.                    localStorage.clear();          // Reset number of hits.          if( localStorage.hits ){         ... Read More

MediaStream in HTML5

Daniol Thomas
Updated on 28-Jan-2020 08:07:51

388 Views

The MediaStream represents synchronized streams of media. If there is no audio tracks, it returns an empty array and it will check video stream, if webcam connected, stream.getVideoTracks() returns an array of one MediaStreamTrack representing the stream from the webcam.function gotStream(stream) {    window.AudioContext = window.AudioContext || window.webkitAudioContext;    var audioContext = new AudioContext();    // Create an AudioNode from the stream    var mediaStreamSource = audioContext.createMediaStreamSource(stream);        // Connect it to destination to hear yourself    // or any other node for processing!    mediaStreamSource.connect(audioContext.destination); } navigator.getUserMedia({audio:true}, gotStream);

What is WebRTC

karthikeya Boyini
Updated on 28-Jan-2020 08:06:20

455 Views

Web RTC introduced by World Wide Web Consortium (W3C). That supports browser-to-browser applications for voice calling, video chat, and P2P file sharing.Web RTC implements three API's as shown below −MediaStream − get access to the user's camera and microphone. RTCPeerConnection − get access to audio or video calling facility. RTCDataChannel − get access to peer-to-peer communication.Web RTC required peer-to-peer communication between browsers. This mechanism required signaling, network information, session control and media information. Web developers can choose a different mechanism to communicate between the browsers such as SIP or XMPP or any two-way communications

Stop Web Workers in HTML5

Nishtha Thakur
Updated on 28-Jan-2020 07:46:34

1K+ Views

Web Workers allow for long-running scripts that are not interrupted by scripts that respond to clicks or other user interactions and allows long tasks to be executed without yielding to keep the page responsive.Web Workers don't stop by themselves but the page that started them can stop them by calling terminate() method.worker.terminate();A terminated Web Worker will no longer respond to messages or perform any additional computations. You cannot restart a worker; instead, you can create a new worker using the same URL.

Creating Content with HTML5 Canvas

Anvi Jain
Updated on 28-Jan-2020 07:44:40

167 Views

Flash provides amazing GUI and lots of visual features for animations. It allows the user build everything inside a particular platform without a full integration into the browser wrapped inside the browser with the main scopes that are multimedia and other kinds of animation.HTML5 element gives you an easy and powerful way to draw graphics using JavaScript. It can be used to draw graphs, make photo compositions or do simple (and not so simple) animations.Here is a simple element which has only two specific attributes width and height plus all the core HTML5 attributes like id, name, and ... Read More

Advertisements