How to disable browser's back button with JavaScript?

George John
Published on 01-Mar-2018 06:22:55
To disable web browsers’ back button, try to run the following code. This is the code for current HTML page, Example<html>    <head>       <title>Disable Browser Back Button</title>       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>       <script src = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>    </head>        <body> ... Read More

Is it safe to assume strict comparison in a JavaScript switch statement?

Priya Pallavi
Published on 01-Mar-2018 06:17:10
To get out of the confusion regarding strict comparison, try to run the following code snippet in JavaScript −Exampleswitch(1) {    case '1':       alert('Switch comparison: Not Strict.');       break;    case 1:       alert('Switch comparison: Strict.');       break;    default:   ... Read More

What is JavaScript AES Encryption?

Arjun Thakur
Published on 01-Mar-2018 06:16:17
AES encryption is Advanced Encryption Standard (AES) to encrypt the data in the application. You can use the JavaScript library Forge to perform AES encryption.Install NPM and install like thisnpm install node-forgeMinify, so that we can use it in our project, npm run minifyNow, use AES-CBC 128 bit encryption ciphers. ... Read More

How to get the body's content of an iframe in JavaScript?

Abhinaya
Published on 01-Mar-2018 06:12:28
To get the body’content, you can get the src attribute or try the following code snippet −<iframe id = "myId" name = " myId ">...</iframe> <script>    var myDoc;    if (window.frames && window.frames. myId && (myDoc = window.frames. myId.document)) {      var iframeBody = myDoc.body;      var ... Read More

Is their a negative lookbehind equivalent in JavaScript?

Ankith Reddy
Published on 01-Mar-2018 06:11:37
For a negative look-behind in JavaScript, use the following −(^|[^\\])"To replace double quotes, you can use the following −str.replace(/(^|[^\\])"/g, "$1'")

How to read data from *.CSV file using JavaScript?

Srinivas Gorla
Published on 01-Mar-2018 06:06:40
To read .CSV using JavaScript, use the open-source CSV parser, Papa Parser. The following are the features −Open SourceParse millions of data using multi-threaded CSV parserSupports multiple web browsersUsing the parser, you can easily skip commented charactersLet’s say your CSV file isn’t on your system. What will you do? Well, ... Read More

How to understand JavaScript module pattern?

George John
Published on 01-Mar-2018 06:09:03
JavaScript does not support classes natively, so the Module pattern is used. This is to store public, private methods, and variables inside a single object. To use and understand it, we will workaround Anonymous closure, to display the voters disqualified since they failed in fulfilling the age criteria of 18 ... Read More

How to convert the image into a base64 string using JavaScript?

Arjun Thakur
Published on 01-Mar-2018 06:00:40
To convert the image into a base64 string using JavaScript, use the FileReader API. You can try to run the following code to get base64string for an image −Example<!DOCTYPE html> <html>    <body>       <script>          function toDataURL(url, callback) {           ... Read More

How to fix Array indexOf() in JavaScript for Internet Explorer browsers?

Ramu Prasad
Published on 01-Mar-2018 05:58:10
To fix Array.indexOf() for Internet Explorer web browser, use the following −jQuery.inArray( value, array [, fromIndex ] )Add the following, <!--[if lte IE 10]>Let’s see the prototype here, <!--[if lte IE 10]> <script>    if (!Array.prototype.indexOf) {       // add code    } </script> <![endif]-->Read More

How to iterate a JavaScript object's properties using jQuery?

George John
Published on 01-Mar-2018 05:50:38
Use the each() method to iterate JavaScript object’s properties.$.each( { name: "Amit", team: "India" }, function(n, l){    alert( "The index is: " + n + ", Value: " + l ); });The above prints −The index is 0, Value: Amit The index is 1, Value: IndiaThe each() is used ... Read More
Advertisements