Found 6710 Articles for Javascript

How to fix problems related to the JavaScript Void 0 Error?

Arjun Thakur
Updated on 16-Jun-2020 08:30:22

2K+ Views

JavaScript void is an error, which can be seen on the web browser. This happened when a user blocks JavaScript coding on the web browser. This gives the void error when an attempt is made to run.The fix is to enable JavaScript. Let us see how to enable it in Firefox web browser −Open Firefox web browser and click Options. After clicking, you will reach the Settings. Here, click the Content tab as shown below −Now, check the box to enable JavaScript. After enabling, click the “Ok” button to save the settings.In newer versions of Firefox, you will get JavaScript ... Read More

How to use window.location to redirect to a different URL?

Jai Janardhan
Updated on 13-Jan-2020 06:26:55

1K+ Views

You might have encountered 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.It is quite simple to do a page redirect using JavaScript on the client side. To redirect your site visitors to a new page, you just need to add a line in your head section as follows.ExampleYou can try to run the following code to learn how to use window.location to redirect an HTML page. Here, we will redirect to the home pageLive Demo           ... Read More

How to use Meta Tag to redirect an HTML page?

Paul Richard
Updated on 13-Jan-2020 06:26:03

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.ExampleLive Demo           HTML Meta Tag                     This is demo text.    

How to use JavaScript to redirect an HTML page?

Rishi Raj
Updated on 07-Oct-2019 08:08:32

2K+ Views

You might have encountered 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.It is quite simple to do a page redirect using JavaScript on the client side. To redirect your site visitors to a new page, you just need to add a line in your head section as follows.You can try to run the following code to learn how to use JavaScript to redirect an HTML page. Here, we will redirect to the homepageExampleLive Demo             ... Read More

How do I redirect my web page with JavaScript?

Shubham Vora
Updated on 20-Jul-2022 08:52:26

4K+ Views

You may have run into a situation where you clicked a URL to go to a certain page but were directed to a different page internally. Page redirection is the cause of this. Redirecting occurs when an HTTP request for one page immediately navigates to another one. It differs from simply reloading a website. It is quite simple to do a web page redirection using vanilla JavaScript on the client side. So in this article, we will learn how to redirect web pages using vanilla JavaScript and when to use a particular method.There are many ways to accomplish redirection of ... Read More

How to find position with HTML5 Geolocation?

Sharon Christine
Updated on 10-Jan-2020 11:15:32

261 Views

HTML5 Geolocation API lets you share your location with your favorite websites. A JavaScript can capture your latitude and longitude and can be sent to backend web server and do fancy location-aware things like finding local businesses or showing your location on a map.The geolocation APIs work with a new property of the global navigator object ie. Geolocation object.The getCurrentPosition method retrieves the current geographic location of the device. The location is expressed as a set of geographic coordinates together with information about heading and speed. The location information is returned to a Position object.ExampleYou can try to run the ... Read More

How to draw on the canvas with JavaScript?

Krantik Chavan
Updated on 15-Jun-2020 11:54:40

633 Views

Drawing on the HTML canvas is to be done with JavaScript. Use the HTML DOM Method getElementById() and getContext() before drawing on the canvas.For that, follow some steps −You need to use the getElementById() method to find the canvas element.Use the getContext(), which is drawing object for the canvas. It provides the methods and properties for drawing.After that draw on the canvas.ExampleYou can try to run the following code to draw canvas on JavaScript −           HTML Canvas                              var canvas = document.getElementById("newCanvas");          var ctxt = canvas.getContext("2d");          ctxt.fillStyle = "#56A7E2";          ctxt.fillRect(0,0,250,120);          

How to add background music to your web page?

Vikyath Ram
Updated on 13-Sep-2023 15:40:09

36K+ Views

To add background music on a web page, use … element. Also, use the autoplay attribute. This will run music in the background whenever the page loads.Set the width and height in a way the player hides on the web page. The loop attribute is added to specify whether the audio will start over again. Add the music file to the server and mention the link in src attribute.ExampleYou can try to run the following code to add background music to your web page:Live Demo           HTML background music             ... Read More

How to draw a star in HTML5 SVG?

Govinda Sai
Updated on 16-Dec-2021 09:34:31

9K+ Views

SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer. Most of the web browsers can display SVG just like they can display PNG, GIF, and JPG.To draw a polygon in HTML SVG, use the SVG element. The element creates a graphic containing at least three sides. For drawing a star in HTML5 SVG, you need to set the x and y coordinates properly for each corner.ExampleYou can try to run the following code to learn how to draw a ... Read More

How to preselect Dropdown Using JavaScript Programmatically?

Shubham Vora
Updated on 15-Sep-2022 12:29:01

2K+ Views

In this tutorial, we will learn how to preselect Dropdown using JavaScript Programmatically. A dropdown list is a toggle menu that allows the user to select one of several options. The options in this list are defined here in coding and are linked to a unique function. When you click or choose this option, that function is triggered and begins to work. A dropdown list allows us to select only one item from a list of options. To construct a basic dropdown list in HTML, the tab is combined with the, tab. Following that, JavaScript assists in performing ... Read More

Advertisements