HTML Articles - Page 133 of 151

What is the usage of onpageshow event in JavaScript?

Nitya Raut
Updated on 21-May-2020 07:46:57

232 Views

The onpageshow event triggers in JavaScript when a user reaches the new web page.ExampleYou can try to run the following code to learn how to implement onpageshow event in JavaScript.           On first visit, a welcome message is visible.                function newFunc() {             alert("Welcome!");          }          

What is the usage of onhashchange event in JavaScript?

Anjana
Updated on 21-May-2020 07:46:11

207 Views

When anchor part is changed, then the onhashchange event occurs. You can try to run the following code to learn how to implement onhashchange event in JavaScript.Example           Click to change anchor                function functionChange() {             location.hash = "about";             var hash = location.hash;             document.write("The anchor part is now: " + hash);          }          // If the achor part is changed          function newFunc() {             alert("Anchor part changed!");          }          

How to stop the execution of a function with JavaScript?

Jennifer Nicholas
Updated on 21-May-2020 07:45:40

9K+ Views

To stop the execution of a function in JavaScript, use the clearTimeout() method. This function call clears any timer set by the setTimeout() functions.ExampleYou can try to run the following code to learn how to work with clearTimeout() method in JavaScript.           JavaScript clearTimeout() method                                                        Click the buttons below to handle animation                              

What is the usage of an abort event in JavaScript?

Sai Nath
Updated on 21-May-2020 07:45:06

467 Views

Use the on abort event to abort the loading of an image. You can try to run the following code to learn how to implement an abort event in JavaScript.Example                    function abortFunc() {             alert('Error- Loading of the image aborted');          }                

What is the role of scrollX property in JavaScript?

Srinivas Gorla
Updated on 20-May-2020 11:01:25

628 Views

The scrollX property in JavaScript works the same as pageXoffset property. If you want to get the pixels the document scrolled to from the upper left corner of the window, then use the scrollX property for horizontal pixels.ExampleYou can try to run the following code to learn how to work with scrollX property in JavaScript.                    div {             background-color: yellow;             height: 1500px;             width: 1500px;          }                              function scrollFunc() {             window.scrollBy(200, 200);             alert("Horizontal: " + window.scrollX);          }             Scroll                      

How to work with document.images in JavaScript?

Arushi
Updated on 20-May-2020 11:00:53

541 Views

Use the document.images property in JavaScript to get the number of tags in a document.ExampleYou can try to run the following code to implement document.images property in JavaScript.Live Demo           JavaScript Example               TutorialsPoint Tutorials                            var num = document.images.length;          document.write("How many images? "+num);          

How to return a random number between 1 and 200 with JavaScript?

Manikanth Mani
Updated on 24-Nov-2023 00:44:49

2K+ Views

To return a random number between 1 and 200, use the JavaScript's Math.random() and Math.floor() method. Example You can try to run the following code to return a random number in JavaScript.                    document.write(Math.floor(Math.random() * 200) + 1);          

How to return a random number between 0 and 199 with JavaScript?

Rama Giri
Updated on 20-May-2020 10:49:10

439 Views

To return a random number between 0 and 199, use the JavaScript Math.random() and Math.floor() method.ExampleYou can try to run the following code to return a random number in JavaScript.                    document.write(Math.floor(Math.random() * 200));          

How to convert Binary to Decimal in JavaScript?

Shubham Vora
Updated on 08-Aug-2022 09:12:08

6K+ Views

In this tutorial, we will learn to convert the binary to decimal in JavaScript. The Binary number is used in digital electronics. It is a string of ‘0’ and ‘1’, representing the number with respect to base 2. Here are the different methods below to convert the binary number to decimal. Using the parseInt() Method In JavaScript, parseInt() method is useful to extract the number from the string. We can define the base for the number as a parameter in the parseInt() method. Syntax Users can follow the below syntax to use the parseInt() method to convert the binary to ... Read More

How to convert Decimal to Binary in JavaScript?

Shubham Vora
Updated on 10-Aug-2022 11:51:59

21K+ Views

This tutorial will teach us to convert the decimal number to a binary number string. The binary number is the string of only 0 and 1. The computer doesn’t understand the high-level programming language, so we need to instruct the computer in a low-level language, represented as the binary string. Also, binary string is used in digital electronics. Here, we have three methods to convert the decimal number to a binary string. Using the toString() Method Using the right shift Operation Using the modulo Operator Using the toString() Method The toString() method is JavaScript built-in string method that ... Read More

Advertisements