function distance(lat1, lon1, lat2, lon2, unit) { if ((lat1 == lat2) && (lon1 == lon2)) { return 0; } else { ...
Get ordinal format of a number in javascript
function getOrdinalNum(n) { return n + (n > 0 ? ['th', 'st', 'nd', 'rd'][(n > 3 && n < 2...
Javascript Code To accept only numbers
You can use HTML5 input type number to restrict only number entries: <input type = "number" name = "someid" ...
Guessing game in javascript
<script> var systemGuess = Math.floor(Math.random() * 100); //alert(systemGuess); while(true){ var userGuess = prompt(...
Create a random Unique ID in javascript
function guid () { function s4 () { return Math . floor (( 1 + Math . random ()) * 0x10000 ) . toString ( 16 ) ...
Disable Right click
<script language="javascript"> document.onmousedown = disableclick; status = "Right Click Disabled";...
How to get the function name in javascript
<script> function abc ( ) { console . log ( arguments . callee . name ) ; } abc ( ) ; </script>
How to apply CSS styles for console using javascript
<script> console.log("%c WARNING!!!", "color:#FF8F1C; font-size:40px;"); console.log("%c This browser fea...
When to use while loop rather than for loop
One main difference is while loops are best suited when you do not know ahead of time the number of iterations that you need to do. When ...
Javascript code to copy text automatically
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js...
Convert minutes to hours in JavaScript
<!DOCTYPE html> <html lang="en"> <head> <title>Convert minutes to String.</title> </...
Get Base64 code from image
<script> function getBase64FromImageUrl(t) { var filesSelected = t.files; if (filesSelected.length > 0) { var fil...
print_r() function in javascript works same as PHP
<!DOCTYPE html> <html> <script> function print_r(theObj){ if(theObj.constructor == Array || theObj.constructo...
Javascript Debugging Beginner tutorial
Beginner Guide to Page and Script Debugging with Chrome Download Examples http://www.codeproject.com/Articles/273129/Beginner-Guid...
How to display Javascript Errors with line and column numbers
window.onerror = function (errorMsg, url, lineNumber, column, errorObj) { alert('Error: ' + errorMsg + ' Script: ' + url ...
Disable Ctrl key combinations using javascript
Hi this is javascript code to disable ctrl + key combinations, onkeydown is the event used for if user press keys on the body then disable...
Display functions in javascript
<p id="myId">Text will display by javascript here</p> <script> alert("string"); console.log(...
Javascript String Methods with Usage examples
A JavaScript string stores a series of characters like "John Doe". A string can be any text inside double or single quotes: ...
Popular Posts
- Instead of Multiple A Name Records why should we need to use Load balancers
- Google Map APIS calculation example
- Deploying Socket.io with FastPanel + Nginx Reverse Proxy + Cloudflare
- Easy form generator for the CodeIgniter framework
- How to configure a localhost website to visible with in the intranet
- How to Copy One MongoDB Database to Another Using mongosh (Without Backup Files)
- Android OS Latest Version 5.0 Name Lollipop officially launched
- Block multiple FTP or SFTP connections from different machines with same username fastpanel
- Judge0 Installation Full steps
- RAG