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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Can we make print button without JavaScript?
In this tutorial, we will learn to make a print button without writing separate JavaScript files. Most websites have print functionality that opens the browser's print dialog when clicked. While HTML doesn't have a built-in print method, we can use the window.print() method directly in HTML attributes. This allows us to create print functionality without external JavaScript files. Syntax The basic syntax for invoking the print method: window.print(); // Opens browser's print dialog Using the onClick Event We can call window.print() directly in HTML using the onClick event attribute. Syntax ...
Read MoreHow to find out which JavaScript events fired?
In this tutorial, we will learn how we can find out which JavaScript event is fired or triggered. We can add events to HTML elements to perform some actions on the webpage like changing text, form submission, etc. There are two ways of finding which JavaScript event is fired − Using Developer Tools Using Inspect Element Let us discuss both of them one by one with coding examples. Using Developer Tools We can find out which JavaScript event is fired by using developer tools in the browser. ...
Read MoreWhat is the difference between local storage vs cookies?
Local storage and cookies are two different ways to store data in web browsers, each with distinct characteristics and use cases. Understanding their differences helps you choose the right storage mechanism for your web application. Storage Capacity Local storage offers significantly more storage space than cookies: Local Storage: Typically 5-10 MB per domain Cookies: Limited to 4 KB per cookie, with a maximum of about 20 cookies per domain Server Communication The key difference lies in how they interact with servers: // Local Storage - stays on client side localStorage.setItem('username', 'john_doe'); ...
Read MoreHow to secure my JavaScript using "Strict mode"?
In this tutorial, we are going to learn how to secure my JavaScript using "Strict mode". There are some errors in the code which are just ignored by the JavaScript engine and if any line fails it performs nothing. To indicate that there is an error we can use strict mode which will make the JavaScript engine throw an error. The 'use strict' is a literal expression which is a directive we can add to the code. We can add this 'use strict' directive to the whole script, a function, or a class. Syntax Now let's see ...
Read MoreHow much data can I store in JavaScript cookies?
JavaScript cookies have size and quantity limits that vary by browser. Understanding these constraints is essential for effective web storage planning. Cookie Storage Limits by Browser Each browser imposes different limits on cookie storage. Here are the current limitations: Web Browser Maximum Cookies per Domain Maximum Size per Cookie Google Chrome 180 ...
Read MoreHow to set src to the img tag in HTML from another domain?
To use an image on a webpage, use the tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load. With HTML, you can add the image source as another domain URL by setting the src attribute to point to an external domain. Syntax Key Attributes Attribute Description src The URL of the image (can be ...
Read MoreHow to set a cookie and get a cookie with JavaScript?
JavaScript cookies allow you to store small pieces of data in the user's browser. You can set cookies using document.cookie and retrieve them by parsing the same property. Setting Cookies The simplest way to create a cookie is to assign a string value to the document.cookie object: document.cookie = "key1=value1;key2=value2;expires=date"; The "expires" attribute is optional. If you provide this attribute with a valid date or time, the cookie will expire on that date and the cookie's value will no longer be accessible. Example: Setting a Cookie This example sets a customer name ...
Read MoreHow to set JavaScript Cookie with no expiration date?
In this tutorial, we will learn how to set JavaScript cookies with no expiration date. Cookies are small data files stored by web browsers that help websites remember user preferences and track behavior. When a cookie has no expiration date, it becomes a session cookie that lasts until the browser is closed. Understanding Cookie Expiration The expires attribute in JavaScript cookies is optional. If you don't specify an expiration date, the cookie will automatically expire when the browser session ends (when the user closes the browser). This type of cookie is called a session cookie. Syntax for ...
Read MoreHow to set src to the img tag in html from the system drive?
To use an image on a webpage, use the tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load. With HTML, you can add the image source as the path of your system drive. For that, add the src attribute as a link to the path of system drive where the image is stored. For example, file:///D:/images/logo.png Important Security and Browser Limitations Note: Modern browsers restrict ...
Read MoreHow do I print Unicode characters in the console using JavaScript?
In this article, we will learn how to print Unicode characters in the console using JavaScript. Unicode assigns a unique number (code point) to each character, enabling consistent representation across different platforms and languages. Unicode is a universal character encoding standard that includes letters from most writing systems, punctuation marks, mathematical symbols, technical symbols, arrows, emoji, and other symbols. JavaScript provides several ways to work with Unicode characters in strings and console output. Using Escape Sequences JavaScript supports Unicode escape sequences to represent characters using their code point numbers. The most common format uses \u followed by ...
Read More