Display Pdf file on web page

In this article, I’ll explain different ways to embed Pdf files in your web application. Method 1: Using the <embed> tag Let’s start with the tag and that is the easiest way to display PDF in browser. This tag allows you to embed the PDF directly within your HTML page. Example: <embed src=”yourfile.pdf” width=”600″ height=”400″ … Read more

Detect Key Press in JavaScript

Detecting key press in javascript can be a very useful feature as it enhances user’s interaction with the web applications. This article explains how can you do it: Keydown Event The keydown event is triggered when user presses down a key. For example: // Detect key press using keydown event document.addEventListener(‘keydown’, function(event) { console.log(‘Key pressed: … Read more

How to Print to Console in Javascript

In this topic, I’ll cover a very common practice that is useful while developing web applications in Javascript to be able to inspect or debug code. The most common way to print information to the console is by using the console.log() method. This will print the message to the browser’s console. Basic Example console.log(‘Hello world!’); … Read more

Text to Speech in JavaScript

Today I’ll explain how to use Web Speech API(SpeechRecognition) in javascript to convert text to speech. Web speech Api allows you to add voice in your web applications. It is pretty simple to use. Here is a simple example showing how you can use the Web Speech API to convert text into speech using JavaScript. … Read more

How to Round a Number in JavaScript

Rounding numbers is a common operation in programming, and JavaScript provides several methods for rounding numbers to the nearest integer or to a specific number of decimal places. In this tutorial, we’ll explore how to round numbers in JavaScript using the built-in Math object. Using Math.round() The Math.round() method rounds a number to the nearest … Read more

How to Replace a Word in a String in JavaScript

JavaScript provides several methods to manipulate strings, including replacing specific words or phrases. In this tutorial, we will explore how to replace a word in a string using the replace() method. Using the replace() Method The replace() method is used to search for a specified substring or regular expression in a string and replace it … Read more