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
-
Economics & Finance
Web Development Articles
Page 104 of 801
Execute a script when a mouse wheel is being scrolled over an element in HTML?
When a mouse wheel is being scrolled over an element, the onwheel attribute triggers a JavaScript function. This event is useful for creating interactive elements that respond to scroll gestures, such as image galleries, zoom controls, or custom scroll behaviors. Syntax Following is the syntax for the onwheel attribute − Content The onwheel attribute can be used with any HTML element. The event object contains information about the scroll direction and delta values. Basic Mouse Wheel Event Example Following example shows how to execute a script when a mouse wheel is ...
Read MoreExecute a script when the browser starts to work online in HTML?
The ononline event attribute in HTML executes a JavaScript function when the browser detects that it has regained internet connectivity. This event is fired when the browser transitions from offline to online mode, making it useful for handling network state changes in web applications. Syntax Following is the syntax for the ononline attribute − The ononline attribute is typically used on the element and calls a JavaScript function when the browser goes online. How It Works The browser monitors network connectivity and fires the online event when: The ...
Read MoreExecute a script when the browser window is closed in HTML?
The onunload event attribute in HTML triggers when the browser window is being closed, refreshed, or navigated away from. This event allows you to execute JavaScript code before the page is completely unloaded from memory. Syntax Following is the syntax for the onunload attribute − You can also use addEventListener in JavaScript − window.addEventListener('unload', function() { // Your code here }); Using onunload Attribute The onunload event fires when the user leaves the page by closing the browser window, clicking a link, refreshing the ...
Read MoreHow to include the audio/video controls in HTML?
The controls attribute in HTML provides built-in playback controls for audio and video elements. When added to or tags, it displays a control bar with play/pause buttons, volume controls, progress bar, and other standard media controls that users expect. Syntax Following is the syntax for the controls attribute − The controls attribute is a boolean attribute, meaning it does not require a value. Its presence enables the controls, while its absence disables them. Video Controls The controls ...
Read MoreExecute a script when the user writes something in a search field in HTML?
The onsearch attribute in HTML allows you to execute a JavaScript function when the user performs a search action in a search input field. This event triggers when the user presses ENTER or clicks the clear button (×) in browsers that support it. Syntax Following is the syntax for the onsearch attribute − The onsearch attribute calls a JavaScript function when a search event occurs on the search input field. Example − Basic Search Event Following example demonstrates how to use the onsearch attribute to capture search input − ...
Read MoreHow to specify the URL of the resource to be used by the object in HTML?
The data attribute in HTML is used to specify the URL of the resource to be used by the element. This attribute defines the location of external content such as images, videos, audio files, Flash files, PDFs, or other multimedia resources that should be embedded in the web page. Syntax Following is the syntax for the data attribute − Alternative content The data attribute accepts a valid URL pointing to the resource file. The URL can be relative (pointing to a file in the same domain) or absolute ...
Read MoreHow to set the audio output of the video to mute in HTML?
Use the muted attribute to set the audio output of the video to mute in HTML. The muted attribute is a boolean attribute that specifies whether the video's audio should be initially silenced when the page loads. Syntax Following is the syntax for the muted attribute − The muted attribute can be written in three ways − muted − Boolean attribute (recommended) muted="muted" − Explicit value muted="" − Empty value How It Works When the muted attribute is present, the video element will start ...
Read MoreSet the shape of the area in HTML
The shape attribute in HTML defines the clickable area's geometry within an image map. It works with the element to create interactive regions on images that users can click to navigate to different links. Syntax Following is the syntax for the shape attribute − The shape attribute accepts four possible values: rect, circle, poly, and default. Each shape type requires specific coordinate formats. Shape Values and Coordinates The following table shows the valid shape values and their coordinate requirements − Shape Value Coordinates Format Description ...
Read MoreExecute a script when a user navigates to a page in HTML?
The onpageshow event in HTML allows you to execute a script whenever a user navigates to a page. This event fires every time a page loads, including when users navigate back using the browser's back button or reload the page. HTML onpageshow Event The onpageshow event occurs when a user navigates to a webpage. Unlike the onload event, onpageshow fires even when the page is loaded from the browser cache, making it ideal for initialization scripts that need to run every time the page is displayed. Syntax Following is the syntax for the onpageshow event in ...
Read MoreExecute a script before the document is printed in HTML?
The onbeforeprint attribute in HTML is an event handler that executes a JavaScript function before a document is printed. This attribute triggers when the user attempts to print the page through browser print functionality (Ctrl+P, File → Print, or print button), displaying custom messages or performing actions before the print dialog appears. The onbeforeprint event is commonly used together with the onafterprint attribute to handle print preparation and cleanup tasks. It belongs to the HTML event attributes category and can be applied to the element or used with JavaScript event listeners. Syntax Following is the syntax ...
Read More