Found 598 Articles for Front End Scripts

HTML5

Lakshmi Srinivas
Updated on 28-Jan-2020 08:31:19

633 Views

Use Mediaplayer of Android for playing audio. You need to call function of Android from JavaScript that you have written in HTML file.WebView wv = (WebView) findViewById(R.id.webview); wv.addJavascriptInterface(new WebAppInterface(this), "Android"); public class WebAppInterface {    Context mContext;    WebAppInterface(Context c) {       mContext = c;    }    @JavascriptInterface    public void showToast(String toast) {       Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();    } }The following is my JavaScript:    function showAndroidToast(toast) {       Android.showToast(toast);    }

How to set focus on a text input in a list with AngularJS and HTML5

karthikeya Boyini
Updated on 28-Jan-2020 08:30:41

486 Views

To set focus on a text input in a list, try the following code:newApp.directive('focus', function () {    return function (scope, element, attrs) {       attrs.$observe('focus', function (newValue) {          newValue === 'true' && element[0].focus();       });    } });The following is the HTML:{{cue.isNewest}}

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 }

Cancels ongoing watchPosition call in HTML5

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

273 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 returned in the PositionError object HTML5 Geolocation

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

403 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

What are Character Entities in HTML5

Samual Sam
Updated on 30-Jul-2019 22:30:22

152 Views

Some characters are reserved in HTML5. For example, you cannot use the greater than and less than signs or angle brackets within your text because the browser could mistake them for markup.HTML5 processors must support the five special characters listed in the table that follows.SymbolDescriptionEntity NameNumber Code"quotation mark""'apostrophe''&ersand&&greater-than>>

How to delete Web Storage?

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

295 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

360 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 Web RTC?

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

423 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.

Advertisements