Javascript Articles

Page 281 of 534

How can I show a euro or other HTML entity in JavaScript alert windows?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

This tutorial will teach us to show a euro or other HTML entities in JavaScript alert windows. JavaScript provides three types of pop-up windows: Alert box, Confirm box, and Prompt box. The alert box displays information to users, such as welcome messages or notifications. The confirm box shows confirmation messages and returns true/false based on user choice. The prompt box collects input from users through a pop-up interface. Default JavaScript alert boxes only display plain text, so we need special techniques to show currency symbols and other HTML entities. We can use Unicode escape sequences, decimal codes, or ...

Read More

How can I delete all cookies with JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 1K+ Views

To delete all cookies with JavaScript, you need to iterate through existing cookies and set their expiration date to the past. JavaScript doesn't provide a direct method to clear all cookies at once, so we must delete them individually. How Cookie Deletion Works Cookies are deleted by setting their expires attribute to a past date. When the browser sees an expired cookie, it automatically removes it from storage. Method 1: Basic Cookie Deletion This approach splits the cookie string and deletes each cookie by name: function deleteAllCookies() { var cookies ...

Read More

How to detect that JavaScript Cookies are disabled?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 5K+ Views

This tutorial will teach you how to detect if cookies are enabled or disabled on a website using JavaScript. Cookies are small text files stored on your computer that contain data. When a web server sends a web page to a browser, it terminates the connection and forgets about the user. Cookies solve the challenge of "how to remember information about the user" by storing data like usernames for subsequent visits. Cookies allow you to store user information between page visits. Your server transmits certain data to the visitor's browser in the form of a cookie, which may be ...

Read More

How to define methods for an Object in JavaScript?

Nancy Den
Nancy Den
Updated on 15-Mar-2026 234 Views

Methods are functions that let an object perform actions or have actions performed on it. The key difference between a function and a method is that a function is a standalone unit of statements, while a method is attached to an object and can be referenced using the this keyword. Methods are used for everything from displaying object contents to performing complex mathematical operations on properties and parameters. Method 1: Defining Methods During Object Creation You can define methods directly when creating an object using object literal notation: let person = { ...

Read More

Getting Safari to recognize HTML 5

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 193 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

Filter gray image, black around png in Internet Explorer 8

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 172 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

What is the difference between new operator and object() constructor in JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 1K+ Views

Both the new operator and Object() constructor are used to create objects in JavaScript, but they serve different purposes and contexts. The new Operator The new operator is used to create an instance of an object. It works with constructor functions to instantiate objects and automatically handles the object creation process. var department = new Object(); var books = new Array("C++", "Perl", "Java"); var day = new Date("December 1, 2017"); document.write("Department: " + typeof department + ""); document.write("Books: " + books + ""); document.write("Date: " + day + ""); ...

Read More

How to make iOS UIWebView display a mobile website correctly?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 175 Views

To make iOS UIWebView display mobile websites correctly, you need to configure both the webview properties and viewport settings. Here are the most effective approaches: Method 1: Using scalesPageToFit Property The primary solution is enabling automatic scaling in your UIWebView: mywebview.scalesPageToFit = YES; mywebview.contentMode = UIViewContentModeScaleAspectFit; This allows the webview to automatically scale content to fit the device screen width. Method 2: JavaScript Zoom Control For fine-tuned control, inject JavaScript to adjust the zoom level: NSString *js = [NSString stringWithFormat:@"document.body.style.zoom = 0.8;"]; [webView stringByEvaluatingJavaScriptFromString:js]; Method 3: Viewport Meta ...

Read More

How to detect all active JavaScript event handlers?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 845 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

Not able to get the value of radio select setting dynamically in AngularJS

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

When working with radio buttons in AngularJS within loops (like ng-repeat), you need to use $index to create unique model bindings for each row. Without it, all radio buttons share the same model and interfere with each other. Problem Radio buttons without proper indexing share the same ng-model, causing unexpected behavior where selecting one affects others. Solution: Using $index Add [$index] to your ng-model to create unique bindings for each iteration: India US Complete Example ...

Read More
Showing 2801–2810 of 5,340 articles
« Prev 1 279 280 281 282 283 534 Next »
Advertisements