Javascript Articles

Page 6 of 534

How to use Meta Tag to redirect an HTML page?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 13K+ Views

Page redirection is a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection.To use a META Tag to redirect your site is quite easy. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute.The following is an example of redirecting current page to another page after 2 seconds. If you want to redirect page immediately then do not specify the content attribute.Example           HTML Meta Tag                     This is demo text.    

Read More

How to append an item into a JavaScript array?

Sravani S
Sravani S
Updated on 11-Mar-2026 295 Views

To append an item to a JavaScript array, use the push() method.ExampleYou can try to run the following code to append an item:                    var arr = ["marketing", "technical", "finance", "sales"];          arr.push("HR");          document.write(arr);           Outputmarketing,technical,finance,sales,HR

Read More

How to create a zero-filled JavaScript array?

Ramu Prasad
Ramu Prasad
Updated on 11-Mar-2026 179 Views

To create a zero-filled JavaScript array, use the Unit8Array typed array.ExampleYou can try to run the following code:                    var arr1 = ["marketing", "technical", "finance", "sales"];          var arr2 = new Uint8Array(4);          document.write(arr1);          document.write("Zero filled array: "+arr2);          

Read More

What is the best way to initialize a JavaScript Date to midnight?

V Jyothi
V Jyothi
Updated on 11-Mar-2026 556 Views

To initialize a JavaScript Date to midnight, set hours like the following −setHours(0,0,0,0);ExampleYou can try to run the following code to set a date to midnight −                    var dt;          dt = new Date();          dt.setHours(0,0,0,0);          document.write(dt);           OutputMon May 28 2018 00:00:00 GMT+0530 (India Standard Time)

Read More

How to get current date/time in seconds in JavaScript?

Abhinanda Shri
Abhinanda Shri
Updated on 11-Mar-2026 737 Views

To convert time in seconds, firstly get the current time. Then, multiply the hours to 3600 and minutes to 60; rest you can see below −(hours*3600) + (min*60) + secExampleYou can try to run the following code to get the current time in seconds −           JavaScript Get Seconds                        var dt = new Date();          var sec = dt.getSeconds();          document.write("Seconds: " + sec);          var min = dt.getMinutes();          document.write("Minutes: " + min);          var hrs = dt.getHours();          document.write("Hours: " + hrs);          var total_seconds = (hrs*3600) + (min*60) + sec;          document.write("Total seconds: " + total_seconds) ;           OutputSeconds: 35 Minutes: 37 Hours: 9 Total seconds: 34655

Read More

How to get Euler's constant value in JavaScript?

Kumar Varma
Kumar Varma
Updated on 11-Mar-2026 890 Views

To get Euler’s constant value in JavaScript, use the Math E property. This is a Euler's constant and the base of natural logarithms, approximately 2.718.ExampleYou can try to run the following code to get Euler’s constant value in JavaScript −           JavaScript Math E Property                        var property_value = Math.E          document.write("Property Value is :" + property_value);           OutputProperty Value is :2.718281828459045

Read More

How to get Natural logarithm of 2 in JavaScript?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 548 Views

To get the Natural logarithm of 2, use the Math.LN2 property in JavaScript. It returns the natural logarithm of 2, which is approximately 0.693.ExampleYou can try to run the following code to get Natural logarithm of 2 −           JavaScript Math LN2 Property                        var property_value = Math.LN2          document.write("Property Value is : " + property_value);           OutputProperty Value is : 0.6931471805599453

Read More

How to create a two dimensional array in JavaScript?

Nikitha N
Nikitha N
Updated on 11-Mar-2026 788 Views

A two-dimensional array has more than one dimension, such as myarray[0][0] for element one, myarray[0][1] for element two, etc. To create a two-dimensional array in JavaScript, you can try to run the following code −Example                                        var myarray=new Array(3);                  for (i=0; i

Read More

How to show all the options from a dropdown list with JavaScript?

Sharon Christine
Sharon Christine
Updated on 11-Mar-2026 5K+ Views

To show all the options from a dropdown list, use the options property. The property allows you to get all the options with length property.ExampleYou can try to run the following code to get all the options from a drop-down list.                                 One             Two             Three                                 Click the button to get all the options                function display() {             var a, i, options;             a = document.getElementById("selectNow");             options = "";             for (i = 0; i < a.length; i++) {                options = options + " " + a.options[i].text;             }             document.write("DropDown Options: "+options);          }          

Read More

How to get the value of the type attribute of a link in JavaScript?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 609 Views

To get the value of the type attribute of a link in JavaScript, use the type property. The type attribute is used to tell that the document is html (text/html) or css (text/css), etc.ExampleYou can try to run the following code to get the value of the type attribute of a link.           Qries                var myVal = document.getElementById("anchorid").type;          document.write("Value of type attribute: "+myVal);          

Read More
Showing 51–60 of 5,339 articles
« Prev 1 4 5 6 7 8 534 Next »
Advertisements