Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 282 of 534
What are secured cookies in JavaScript?
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 MoreBlank PNG image is shown with toBase64Image() function
If a blank PNG image is shown with the toBase64Image() function, this typically occurs because the function is called before the chart finishes rendering. Here are two solutions to ensure the chart is fully rendered before converting to base64. Solution 1: Using Animation onComplete Callback Wait for the chart animation to complete before calling toBase64Image(): animation: { duration: 2000, onComplete: function (animation) { var base64Image = this.toBase64Image(); console.log(base64Image); ...
Read MoreHow to use the 'with' keyword in JavaScript?
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 MoreHow to create multi-column layout in HTML5 using tables?
Design your webpage to display content across multiple columns using HTML tables. This approach allows you to create structured layouts with a main content area in the center, navigation menu on the left, and additional content like advertisements on the right. Basic Three-Column Layout Structure Tables provide a simple way to create multi-column layouts by using table rows () and table data cells (). Each cell acts as a separate column with customizable width and styling. Example Three Column HTML Layout ...
Read MoreHow to list down all the cookies by name using JavaScript?
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 MoreHow to use JavaScript to set cookies for homepage only?
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 MoreUnicode Byte Order Mark (BOM) character in HTML5 document.
A byte order mark (BOM) consists of the character code U+FEFF at the beginning of a data stream, where it can be used as a signature defining the byte order and encoding form, primarily of unmarked plaintext files. In HTML5 documents, the BOM can help browsers automatically detect the file's encoding. What is a BOM? Many Windows programs (including Windows Notepad) add the bytes 0xEF, 0xBB, 0xBF at the start of any document saved as UTF-8. This is the UTF-8 encoding of the Unicode byte order mark (BOM), and is commonly referred to as a UTF-8 BOM even ...
Read MoreHow to use JavaScript to set cookies for a specific page only?
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 MoreHow to create domain-based cookies using JavaScript?
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 MoreAn empty box is displayed instead of the rupee symbol in HTML
When displaying the Indian rupee symbol (₹) in HTML, you might encounter an empty box instead of the symbol due to browser compatibility or font issues. Here are reliable solutions to ensure proper rupee symbol display. The Problem The rupee symbol using HTML entity ₹ may not display correctly in all browsers or devices: ₹ This can appear as an empty box □ if the browser or font doesn't support the Unicode character. Using Font Awesome Icons (Recommended) Font Awesome provides cross-browser compatible rupee icons: ...
Read More