Object Oriented Programming Articles

Page 76 of 589

Difference between window.location.href, window.location.replace and window.location.assign in JavaScript?

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 775 Views

The window object includes the location object in JavaScript, which provides three different methods for navigating between pages. Each method has distinct behavior regarding browser history and navigation. window.location.href The href property gets or sets the complete URL of the current page. When assigned a new value, it navigates to that URL and adds an entry to the browser's history stack. Example Click below to get the complete URL of the page. Get Current URL ...

Read More

Which is the best JavaScript compressor?

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 275 Views

JavaScript compressors reduce file sizes by removing unnecessary whitespace, comments, and optimizing code structure. Here are the best options available for different needs. Google Closure Compiler Google Closure Compiler is one of the most powerful JavaScript optimization tools. It parses JavaScript, analyzes it, removes dead code, rewrites inefficient patterns, and minimizes the output. Unlike simple minifiers, it performs advanced optimizations like function inlining and variable renaming. Original JS function add(a, b){ return a + b; ...

Read More

How to set the length of the item relative to the rest with JavaScript?

Abhinaya
Abhinaya
Updated on 15-Mar-2026 181 Views

Use the flex property in JavaScript to set the length of flex items relative to each other. The flex property controls how much space a flex item should take up within a flex container. Syntax element.style.flex = "value"; The flex value can be a number (flex-grow), or a combination of flex-grow, flex-shrink, and flex-basis values. Example #box { ...

Read More

How to make flexible items display in columns with JavaScript?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 269 Views

The flexFlow property in CSS controls how flexible items are arranged within a flex container. To display items in columns using JavaScript, you can modify this property dynamically. Understanding flexFlow The flexFlow property is a shorthand that combines flex-direction and flex-wrap. For column layout, use column for direction and nowrap or wrap for wrapping behavior. Example Here's how to change flexible items from row to column layout using JavaScript: #box { ...

Read More

How to set the page-break behavior after an element with JavaScript?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 928 Views

Use the pageBreakAfter property in JavaScript to control page-break behavior after an element. This property is essential for formatting printed documents and print previews. Note: Changes are only visible when printing the page or viewing print preview (Ctrl+P). Syntax element.style.pageBreakAfter = "value"; Property Values Value Description auto Default - automatic page breaks always Forces page break after element avoid Avoids page break after element left Forces page break to left page right Forces page break to right page ...

Read More

How to set the page-break behavior inside an element with JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 3K+ Views

Use the pageBreakInside property in JavaScript to control page-break behavior inside an element when printing. This property determines whether a page break should occur within an element's content. Note − The changes are only visible when printing or viewing the print preview. Syntax element.style.pageBreakInside = "value"; Property Values Value Description auto Allow page breaks inside the element (default) avoid Avoid page breaks inside the element if possible inherit Inherit from parent element Example: Setting Page Break Behavior Here's how to control ...

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 173 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

How to use JavaScript Object.defineProperty?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 317 Views

The Object.defineProperty() method allows you to define a new property or modify an existing property on an object with precise control over its behavior. Syntax Object.defineProperty(obj, prop, descriptor) Parameters obj – The object on which to define the property prop – The name of the property to be defined or modified descriptor – An object that describes the property's attributes Property Descriptor Attributes The descriptor object can contain the following attributes: value – The value of ...

Read More

How to set the minimum number of lines for an element that must be visible at the top of a page in JavaScript?

George John
George John
Updated on 15-Mar-2026 190 Views

The orphans CSS property sets the minimum number of lines in a block container that must be shown at the top of a page when a page break occurs. In JavaScript, you can control this property through the DOM to manage print layout behavior. Syntax // Get the orphans value var orphansValue = element.style.orphans; // Set the orphans value element.style.orphans = "number|initial|inherit"; Parameters Value Description number Minimum number of lines (default is 2) initial Sets to default value inherit Inherits from parent element ...

Read More

How to set the alignment between the items inside a flexible container when the items do not use all available space with JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 160 Views

The alignContent property in JavaScript controls how flex lines are distributed within a flex container when there's extra space on the cross axis. This property only works when items wrap to multiple lines. Syntax element.style.alignContent = "value"; Available Values The alignContent property accepts these values: flex-start - Lines packed toward the start flex-end - Lines packed toward the end center - Lines packed toward the center space-between - Lines evenly distributed space-around - Lines with equal space around them stretch - Lines stretch to fill the container (default) Example ...

Read More
Showing 751–760 of 5,881 articles
« Prev 1 74 75 76 77 78 589 Next »
Advertisements