Found 448 Articles for Programming Scripts

What is the usage of an abort event in JavaScript?

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

299 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

448 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                      

What is the role of scrollY property in JavaScript?

Ayyan
Updated on 20-May-2020 11:02:34

291 Views

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

How to work with document.images in JavaScript?

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

331 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

1K+ 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

289 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

19K+ 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

How to work with document.embeds in JavaScript?

Jai Janardhan
Updated on 20-May-2020 10:51:40

120 Views

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

What is JavaScript Bitwise XOR (^) Operator?

Abhinaya
Updated on 20-May-2020 10:50:12

191 Views

If both the bits are different, then 1 is returned when Bitwise OR (|) operator is used.ExampleYou can try to run the following code to learn how to work with JavaScript Bitwise XOR Operator.                    document.write("Bitwise XOR Operator");          // 7 = 00000000000000000000000000000111          // 1 = 00000000000000000000000000000001          document.write(7 ^ 1);          

Advertisements