Found 6710 Articles for Javascript

How to stop browser's back button using JavaScript?

Shubham Vora
Updated on 16-Feb-2023 16:47:59

15K+ Views

Stopping the browser’s back button meaning is that preventing users from going to the previous page. Sometimes, we need to prevent users from going to the back of the current page for security purposes. For example, most bank sites don’t allow you to go back when you are doing some transaction from their site using online banking. Because if users go back from the midtransaction, it can create some issues. So, it only allows you to either complete the transaction or cancel the transaction and start it again. Here, we will learn various approaches to prevent users from going ... Read More

How to append data to

AmitDiwan
Updated on 16-Feb-2023 11:02:57

23K+ Views

We can append data to an element using JavaScript by using the .innerHTML property to add content to the element. This can be done by using the += operator to add the new content to the existing content within the . We can also use the .appendChild() method to add a new child element to the . is a block-level element that is used to create a division or section in an HTML document. The element is usually used to group elements together, such as paragraphs, headings, or images. The element can also be used to ... Read More

How to align text content into center using JavaScript?

AmitDiwan
Updated on 13-Feb-2023 17:57:00

14K+ Views

We can align text content into the center using JavaScript by manipulating the CSS properties of the element. This can be done by selecting the element and setting the "text-align" property to "center". Additionally, we can also use the "margin" property to adjust the positioning of the element. Approach There are multiple ways to center text content using JavaScript − The most common way is to set the text-align property to “center” in the CSS stylesheet. Another way is to use the tag. Finally, you can use the margin property to center text content. ExampleBelow we will be ... Read More

How to align images on a card with a dynamic title in Javascript?

AmitDiwan
Updated on 13-Feb-2023 17:54:45

2K+ Views

We can align images in a card by using CSS to set the position and margins of the image within the card container. We can also use Flexbox or Grid to align the image and title in a specific way. By using dynamic title, we can change the text displayed in the card title based on user input or data from a database. Approach Start by creating a container for your card. This can be a div or a section element. Within this container, add a div or a header element to hold your dynamic title. Make sure to ... Read More

How to align flexbox container into center using JavaScript?

AmitDiwan
Updated on 13-Feb-2023 17:52:18

3K+ Views

To align a flexbox container into the center using JavaScript, we first need to select the container using a DOM manipulation method such as querySelector. Next, we need to set the container's CSS properties to "display: flex" and "justify-content: center". This will align the items within the container to the center horizontally. Flexbox is a layout mode in CSS3 that lets you align and distribute elements on a page. It can be used for things like creating a main navigation bar or laying out a photo gallery. Flexbox is a powerful tool that can make your web layouts more flexible ... Read More

How to adjust the Width of Input Field Automatically using JavaScript?

AmitDiwan
Updated on 13-Feb-2023 17:50:07

9K+ Views

We can use JavaScript to adjust the width of an input field automatically. This can be done by using the element's style property to set the width based on the input's value. By constantly updating the width as the user types, we can ensure that the input field is always the appropriate size for the input. Here is one approach to adjust the width of an input field automatically using JavaScript − Select the input field using JavaScript, for example, by using the document.querySelector() method − var inputField = document.querySelector("#myInput"); Add an event listener to the ... Read More

How to add Summernote Editor to the webpage in Javascript?

AmitDiwan
Updated on 13-Feb-2023 17:25:44

4K+ Views

To add Summernote Editor in a webpage, we first need to include the Summernote CSS and JS files in the head of our HTML document. Next, we need to initialize the Summernote editor on a specific text area or div element by calling the Summernote function on it. Finally, we can customize the editor's options and functionality by passing options as an object to the Summernote function. Let us first understand what Summernote editor is. What is Summernote? Summernote is a JavaScript library that allows for the creation and editing of rich text within a web page. It is ... Read More

How a Polygon is different from a Polyline in FabricJS?

Rahul Gurung
Updated on 16-Feb-2023 15:58:08

425 Views

We can create a Polyline object by creating an instance of fabric.Polyline while fabric.Polygon can be used to create a Polygon instance. A polyline object can be characterised by a set of connected straight-line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. A polygon always connects the first point to the last to make a closed area while a polyline doesn’t. This can be proved by the examples given below. Syntax new fabric.Polyline(points: Array, options: Object) Parameters points − This ... Read More

How to clear cache memory using JavaScript?

Rushi Javiya
Updated on 31-Oct-2023 02:57:17

36K+ Views

Cache memory, often known as cache, is a different memory system in a computer that stores frequently used data and instructions for a short period. While loading a website, the browser we are using will automatically cache some resources, such as images, scripts, and stylesheets, to be utilized again when the page is reloaded. This can shorten the time it takes for a website to load not only that but also it helps to lower the amount of data that has to be sent over the network. But this cache memory stored by the browser also has some disadvantages. If ... Read More

How to check whether the background image is loaded or not using JavaScript?

Rushi Javiya
Updated on 08-Feb-2023 20:26:32

2K+ Views

We mainly use JavaScript to create dynamic web applications. This kind of scripting language makes a web page look interactive. JavaScript significantly adds some logic to our website. As we mentioned, the user can check whether the background image is loaded. Web developers can understand that the page is loaded correctly and that the background image is displayed properly. To check whether the background image is loaded as directed by the web developers on the web page user can use the image object. We can access this object's properties and methods related to an image, and we can apply ... Read More

Advertisements