Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Javascript Articles - Page 535 of 671
165 Views
To enhance the performance of Canvas with particles bouncing around, try the following:Separate the calculations from the drawing.Request a redraw after you have updated your calculations.Optimize collision detection by not testing evert particle against each other.Reduce callback usage.Reduce function calls.Inline.
652 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); }
493 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}}
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 }
281 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
418 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
159 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>>
