Front End Technology Articles

Page 331 of 652

How can I pop-up a print dialog box using JavaScript?

Amit Sharma
Amit Sharma
Updated on 15-Mar-2026 4K+ Views

To pop-up a print dialog box using JavaScript, use the window.print() method. This method opens the browser's print dialog, allowing users to select printing options like printer choice, page range, and paper size. Syntax window.print(); Basic Example Here's a simple example that opens the print dialog when a button is clicked: Print Dialog Example My Document This content will be printed when you click the print button. ...

Read More

How to create JavaScript objects using new operator?

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

The new operator in JavaScript creates instances of objects. It can be used with built-in constructors like Object(), Array(), or with custom constructor functions to create objects with specific properties and methods. Syntax let objectName = new ConstructorFunction(parameters); Using new with Object Constructor The most basic way is using new Object() to create an empty object, then add properties: var dept = new Object(); dept.employee ...

Read More

How to set multiple cookies in JavaScript?

mkotla
mkotla
Updated on 15-Mar-2026 4K+ Views

In JavaScript, you can set multiple cookies by calling document.cookie multiple times. Each call adds a new cookie to the browser's cookie store. Unlike other properties, document.cookie doesn't overwrite existing cookies — it appends new ones. Basic Syntax for Multiple Cookies document.cookie = "cookie1=value1"; document.cookie = "cookie2=value2"; document.cookie = "cookie3=value3"; Example: Setting Multiple Cookies Here's a complete example showing how to add, list, and remove multiple cookies: var num = 1; ...

Read More

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

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 detect all active JavaScript event handlers?

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

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
Showing 3301–3310 of 6,519 articles
« Prev 1 329 330 331 332 333 652 Next »
Advertisements