Using Javascript to scroll up or down a webpage
Using Javascript to scroll up and down the webpage problem You wish to perform a dynamic scroll of the webpage vertically or horizontally. In this post we will see how to perform a scroll using Javascript. SOLUTION In Javascript, we have the scroll() method provided by the window object. Let’s see an example, but first […]
3 ways to add JavaScript to your page
3 ways to add JavaScript to your page problem You wish to add some JavaScript code to your web page to make more interactive. Tag One classic way is by using the script tag. For example: Preferably after the body tag so it’s loaded more efficiently. inline JavaScript can also be added inline, in an […]
Show a confirmation popup in JavaScript
What are the types of popups available in javascript? Popup boxes can be used for asking the user for confirmation.
Collatz (3n + 1) sequence in JavaScript
Collatz (3n + 1) sequence in JavaScript problem You wish to generate the Collatz sequence using JavaScript. In this post we will see how to accomplish that and print in the console of the web browser that is in the web developer tools of each popular web browser. Recall the Collatz sequence starts by giving […]
Simple AJAX example in JavaScript
Problem You have designed a web application with frontend and backend. The frontend page wishes to send an Asynchronous And JavaScript XML (AJAX) request to the backend and update a small portion of the page with the response that is text. The AJAX was introduced to make our websites look more like Desktop applications in […]
html add action on click of a button
html add action on click of a button Problem You are designing a webpage and wish to place a button that does something when you click it. This post we will use a simple HTML code that has a button and when you click it shows a hello popup. Solution A simple HTML page with […]
How to use a timer in JavaScript
How to use a timer in JavaScript Problem You are designing a web page and wish to add interactivity that will be occurring periodically. For example, it will be sending a request to an API every 10 seconds to retrieve information. For this post, we will use an example of updating a number incrementally every […]