Web Development Articles

Page 335 of 801

How to detect all active JavaScript event handlers?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 849 Views

JavaScript doesn't provide a built-in method to detect all active event handlers on a page. However, there are several approaches to identify event listeners attached to DOM elements. Using jQuery to Detect Event Handlers jQuery provides a convenient way to access event data for elements that have jQuery event handlers attached. Demo Text // Attach jQuery event handler ...

Read More

HTML5 meta name = "viewport" doesn't work as expected

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 844 Views

The HTML5 viewport meta tag controls how web pages are displayed on mobile devices. When it doesn't work as expected, it's often due to incorrect syntax or conflicting properties. Common Issues and Solutions Here are the most effective viewport configurations to fix common display problems: Method 1: Standard Responsive Design For most responsive websites, use this configuration: Responsive Page This page adapts to screen width Content scales properly on all devices. ...

Read More

What are secured cookies in JavaScript?

Daniol Thomas
Daniol Thomas
Updated on 15-Mar-2026 2K+ Views

Secured cookies in JavaScript are cookies with special security attributes that protect against common web vulnerabilities. They use two main flags: Secure and HttpOnly to enhance security. What Makes a Cookie Secured? A secured cookie has two key attributes: Secure flag - Cookie is only sent over HTTPS connections HttpOnly flag - Cookie cannot be accessed via JavaScript The Secure Attribute The Secure attribute ensures cookies are only transmitted over encrypted HTTPS connections, preventing interception over unsecured HTTP. // Setting a secure cookie (server-side example) document.cookie = "sessionId=abc123; Secure; Path=/"; ...

Read More

Getting Safari to recognize HTML 5

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 197 Views

Safari versions prior to 7.0 don't recognize HTML5 semantic elements like , , , and . These elements are treated as inline by default, which can break your layout. The Problem In older Safari browsers, HTML5 elements don't have default block-level styling, causing layout issues when you expect them to behave like elements. Solution: CSS Display Block The key is to explicitly set display: block for HTML5 semantic elements: main { display: block; width: 800px; height: 800px; ...

Read More

How to use the 'with' keyword in JavaScript?

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 6K+ Views

The with keyword in JavaScript creates a shorthand for referencing an object's properties and methods. However, it's deprecated and not recommended in modern JavaScript due to performance and security issues. Syntax with (object) { // properties used without the object name and dot } Basic Example Here's how with works with a simple object: JavaScript with Statement var person = { ...

Read More

Filter gray image, black around png in Internet Explorer 8

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 176 Views

In Internet Explorer 8, applying grayscale filters to PNG images often creates unwanted black backgrounds. This happens because IE8's filter system doesn't handle PNG transparency properly when multiple filters are applied. The Problem When using BasicImage(grayscale=1) filter on PNG images with transparency in IE8, the transparent areas become black instead of remaining transparent. Solution: Combining Gradient and BasicImage Filters The solution is to combine a transparent gradient filter with the grayscale filter in a single filter declaration: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF, endColorstr=#00FFFFFF) progid:DXImageTransform.Microsoft.BasicImage(grayscale=1) Complete CSS Implementation .demo { background: ...

Read More

How to list down all the cookies by name using JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 328 Views

To list all cookies by name in JavaScript, you access the document.cookie property, split it into individual cookie pairs, and extract the name-value pairs from each cookie. How document.cookie Works The document.cookie property returns all cookies as a single string, with each cookie separated by semicolons. For example: "name1=value1; name2=value2; name3=value3". Method 1: Basic Cookie Listing Here's a simple approach to list all cookies by splitting the cookie string: function ReadCookie() { ...

Read More

How to use JavaScript to set cookies for homepage only?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 381 Views

Setting cookies for a specific page like the homepage requires checking the current page URL before creating the cookie. This ensures the cookie is only set when users are on the designated homepage. Understanding the Approach To restrict cookie setting to the homepage only, we need to: Get the current page URL using window.location.pathname Check if the current page matches our homepage criteria Set the cookie only if the condition is met Example: Setting Cookies for Homepage Only ...

Read More

How to use JavaScript to set cookies for a specific page only?

Abhishek Kumar
Abhishek Kumar
Updated on 15-Mar-2026 3K+ Views

We can set cookies for a specific page only using JavaScript. We use the path attribute of the document.cookie property to set the cookie on a specific webpage. Cookies are small text files (4 KB) that store important information such as username, email, session id, and other preferences that help customize the webpage for a particular user. The pathname property of the Window location returns a string containing the path of the current webpage. The path is basic information about where the current webpage is stored on the server. document.cookie Syntax The document.cookie property returns a list ...

Read More

How to create domain-based cookies using JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 421 Views

To create a domain-based cookie, set the domain and path attribute on your cookie. Domain-based cookies are accessible across all subdomains of the specified domain. Syntax document.cookie = "cookieName=value; domain=.example.com; path=/"; Domain Cookie Format domain=.example.com The dot prefix (.) makes the cookie available to all subdomains like www.example.com, api.example.com, etc. Example: Setting Domain-Based Cookie function WriteCookie() { if( document.myform.customer.value == "" ...

Read More
Showing 3341–3350 of 8,010 articles
« Prev 1 333 334 335 336 337 801 Next »
Advertisements