Srinivas Gorla

Srinivas Gorla

45 Articles Published

Articles by Srinivas Gorla

45 articles

How to specify the kind of text track in HTML?

Srinivas Gorla
Srinivas Gorla
Updated on 16-Mar-2026 197 Views

The kind attribute in HTML is used to specify the type of text track for the element. This attribute helps browsers understand how to handle and display different types of text tracks, such as subtitles, captions, descriptions, chapters, or metadata. Syntax Following is the syntax for the kind attribute − The kind attribute accepts one of the following values − subtitles − Translation of dialogue and sound effects (default value) captions − Transcription of dialogue, sound effects, and other audio information descriptions − Textual descriptions of video content for visually ...

Read More

Execute a script when the window's history changes in HTML?

Srinivas Gorla
Srinivas Gorla
Updated on 16-Mar-2026 219 Views

The onpopstate event in HTML triggers when the browser's history changes, such as when a user clicks the back or forward button. This event is essential for handling navigation in single-page applications and managing browser history programmatically. Syntax Following is the syntax for the onpopstate event − In JavaScript, you can also add the event listener programmatically − window.addEventListener('popstate', functionName); How It Works The onpopstate event fires when the active history entry changes. This happens when users navigate using browser buttons (back/forward) or when history.back(), history.forward(), or history.go() ...

Read More

Create a syntax highlighting code with JavaScript.

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 230 Views

Creating syntax highlighting for code blocks enhances readability and user experience. JavaScript offers several libraries for this purpose, with Google's Prettify being one of the simplest options. Using Google Prettify Library Prettify is a lightweight JavaScript library that automatically highlights code syntax. Include it in your HTML document: Basic Implementation Add the prettyprint class to any or element: function greetUser(name) { return "Hello, " + name + "!"; } ...

Read More

What will happen if a semicolon is misplaced in JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 259 Views

If a semicolon is misplaced in JavaScript, it can lead to unexpected behavior due to Automatic Semicolon Insertion (ASI). JavaScript automatically inserts semicolons at the end of statements, which can sometimes cause logical errors when semicolons are placed incorrectly. Common Semicolon Misplacement Issues The most common problem occurs when a semicolon is accidentally placed after control flow statements like if, for, or while. Example: Semicolon After if Statement var val1 = 10; ...

Read More

How to set the minimum number of lines for an element that must be left at the bottom of a page when a page break occurs inside an element with JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 165 Views

The orphans property in CSS controls the minimum number of lines that must remain at the bottom of a page when a page break occurs inside an element. In JavaScript, you can manipulate this property through the style object. Syntax To get the orphans property: var result = element.style.orphans; To set the orphans property: element.style.orphans = 'number|initial|inherit'; Property Values number − Specify the minimum number of visible lines that must remain at the bottom initial − Set property to its default value ...

Read More

What is the role of scrollX property in JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 644 Views

The scrollX property in JavaScript returns the number of pixels the document has been scrolled horizontally from the left edge of the viewport. It's equivalent to the older pageXOffset property and is read-only. Syntax let horizontalScroll = window.scrollX; Return Value Returns a number representing the horizontal scroll position in pixels. The value is 0 when the document is not scrolled horizontally. Example: Basic scrollX Usage .content { ...

Read More

What is the role of clearTimeout() function in JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 342 Views

The clearTimeout() function cancels a timeout that was previously set with setTimeout(). When you call setTimeout(), it returns a timeout ID that you can use with clearTimeout() to stop the scheduled execution. Syntax clearTimeout(timeoutID) Parameters timeoutID - The identifier returned by setTimeout() that you want to cancel Basic Example clearTimeout Example Start Timer Cancel Timer ...

Read More

How can I access document properties using Legacy DOM method in JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 239 Views

To access document properties using Legacy DOM methods in JavaScript, you can use various built-in properties and collections that provide information about the document structure and content. Common Legacy DOM Properties The Legacy DOM provides several properties to access document information: document.title - Gets the document title document.URL - Gets the complete URL document.forms - Collection of all forms document.images - Collection of all images document.links - Collection of all links Example Document Title ...

Read More

How can we debug JavaScript in Internet Explorer?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 268 Views

Debugging JavaScript in Internet Explorer requires enabling built-in error reporting and using developer tools. While Internet Explorer is now legacy, understanding these techniques helps with maintaining older applications. Enabling Error Notifications By default, Internet Explorer shows a small error icon in the status bar when JavaScript errors occur. This icon is easily missed, so you can enable automatic error dialogs. To enable automatic error notifications: Open Internet Explorer Go to Tools → Internet Options → Advanced tab Check "Display a notification about every script error" Click OK to save changes ...

Read More

How to return a value from a JavaScript function?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 3K+ Views

To return a value from a JavaScript function, use the return statement. The return statement sends a value back to the code that called the function and immediately exits the function. Syntax function functionName() { // function body return value; } Example: Basic Return Statement function concatenate(name, age) { var val = name + age; ...

Read More
Showing 1–10 of 45 articles
« Prev 1 2 3 4 5 Next »
Advertisements