Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Javascript Articles
Page 6 of 534
How to use Meta Tag to redirect an HTML page?
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 MoreHow to append an item into a JavaScript array?
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 MoreHow to create a zero-filled JavaScript array?
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 MoreWhat is the best way to initialize a JavaScript Date to midnight?
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 MoreHow to get current date/time in seconds in JavaScript?
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 MoreHow to get Euler's constant value in JavaScript?
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 MoreHow to get Natural logarithm of 2 in JavaScript?
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 MoreHow to create a two dimensional array in JavaScript?
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 MoreHow to show all the options from a dropdown list with JavaScript?
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 MoreHow to get the value of the type attribute of a link in JavaScript?
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