Javascript Articles - Page 582 of 671

How to return a number of bits used to display one color on a window screen in JavaScript?

Prabhdeep Singh
Updated on 07-Nov-2022 06:57:03

239 Views

In this tutorial, we will explore how we can find out the number of bits that are used to display a single color on the screen of our device using JavaScript. JavaScript has many inbuilt functions that allow us to get information about the various properties of the display screen. We’ll be using one such function to accomplish the task mentioned above. As discussed in the previous section, we want to find out the exact number of bits that are used to display a particular color on the user’s display screen by using JavaScript. Before we can access the number ... Read More

How to work with document.links in JavaScript?

Shubham Vora
Updated on 15-Nov-2022 10:26:59

1K+ Views

In this tutorial, let us discuss how to work with the document's link in JavaScript. The document link property is a read-only DOM level 1 feature that returns all the links. The links property gives all the anchor elements and area tags with a href attribute. Working with document.links properties Let us learn to work with a link's properties. Users can follow the syntax below to work with the link's properties. Syntax let links = document.links; links.propertyName; The above syntax returns all anchor tags, area tags, and properties. Properties length − The length is the number of elements ... Read More

How to work with document.images in JavaScript?

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

509 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);          

What are the properties of window.screen object in JavaScript?

Shubham Vora
Updated on 31-Oct-2022 11:16:00

524 Views

In this tutorial, we will discuss the properties of the window.screen object in JavaScript. The window comes under the Browser Object Model – BOM. The window's screen object holds information on the user's screen. Because the scope of the window object is high, we can also write the window's screen object as "screen". There are no direct methods for the screen object. The object's use is to improve the UI experience of a webpage. Properties of window.screen Object availHeight The availHeight property returns the screen height, excluding the Windows Taskbar. availWidth The availWidth property returns the screen width, excluding the ... Read More

How to return the protocol (http or https) of the web page with JavaScript?

Prabhdeep Singh
Updated on 07-Nov-2022 08:02:14

1K+ Views

In this tutorial, we will look at how to find which protocol is being used by a web page. A web page mostly uses http or https protocol. A protocol is a type of standard which is used to specify, how the data is transferred or transmitted between different sets of computer. HTTP − HTTP is a protocol for retrieving resources such as HTML pages. It is one of the most essential and the backbone for all types of data exchange that happens over the internet. HTTP is a client server protocol which means that all the requests are done ... Read More

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 work with document.forms in JavaScript?

Shubham Vora
Updated on 31-Oct-2022 11:11:45

4K+ Views

In this tutorial, let us discuss how to work with document.forms in JavaScript. The document.form property returns all the form tags in the document. The forms property is read-only. The form property is the Dom level 1 feature. Working with form attributes and elements Here let us learn to work with a form's properties, attributes, and elements. Users can follow the syntax below to work with the form's properties and elements. Syntax var forms = document.forms; let formLen = forms.length; let formId = forms[0].id || forms.item(0).id; let formItemId = forms[0].elements[0].id; let formItemVal = forms[0].elements[0].value; let formData = forms.namedItem("testForm").innerHTML; The ... Read More

How to work with document.head in JavaScript?

Shubham Vora
Updated on 15-Nov-2022 09:14:52

2K+ Views

In this tutorial, let us discuss how to work with the document's head in JavaScript. The document head property is a dom level 3 read-only feature. The document's head property returns all the head tags in the document. HTML adds an empty head tag in case it is not present. The property returns the first head element in case there are many. The head tag contains the document header information like title, keywords, description, and style sheet. Every document needs a head tag. But start and end tags are optional. The first body tag or the first frameset tag becomes ... Read More

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

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

412 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

Advertisements