Found 9053 Articles for Front End Technology

How to set JavaScript Cookie with no expiration date?

Prabhdeep Singh
Updated on 07-Nov-2022 08:25:24

1K+ Views

In this tutorial, we are going to learn to set a JavaScript cookie with no expiration date. Web servers deliver cookies, which are tiny files with frequently unique identifiers, to browsers. Each time your browser requests a new page, the server will receive these cookies. It allows a website to keep track of your preferences and online behavior. The expiration option in a JavaScript cookie is optional. The “expires” attribute is optional. If you provide this attribute with a valid date or time, then the cookie will expire on a given date or time, and thereafter, the cookies' value will ... Read More

How do I create and read a value from the cookie in JavaScript?

usharani
Updated on 16-Jun-2020 11:50:52

93 Views

Create cookiesThe simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this −document.cookie = "key1=value1;key2=value2;expires=date";Here the “expires” attribute is optional. If you provide this attribute with a valid date or time, then the cookie will expire on a given date or time and thereafter, the cookies' value will not be accessible.ExampleTry the following. It sets a customer name in an input cookie.Live Demo                                                 ... Read More

How do I print Unicode characters in the console using JavaScript?

Shubham Vora
Updated on 22-Jul-2022 12:55:58

2K+ Views

In this article, we will learn how to print Unicode characters in the console using JavaScript. No matter the platform, the software, or the language, Unicode assigns a unique number to each character.Most writing systems' characters are defined by the universal character set known as Unicode, which also assigns each character a unique number (code point). A unit of data called an abstract character (or character) is used to organize, manage, or represent textual data.Most of the modern languages' letters, punctuation marks, diacritical markings, mathematical symbols, technical symbols, arrows, emoji, and other symbols are all included in Unicode.These are different ... Read More

How to set Heading alignment in HTML?

Lokesh Badavath
Updated on 02-Sep-2023 13:50:46

47K+ Views

Headings are the titles or subtitles of the content that you want to display on the web page. Headings help us to get an idea of the content on the web page. Headings and subheadings represent the key concepts ideas and supporting ideas in the content of the web page. HTML have a different level of heading tags. Heading is defined with to tags. It is important to use headings to show the HTML document structure. headings should be used for main headings, followed by headings, then , and so on up to . Heading tags ... Read More

How do I print a message to the error console using JavaScript?

Ali
Ali
Updated on 16-Jun-2020 13:52:32

188 Views

To print a message to the error console, use the console object. Here’s an example −The following will show a red error message −console.error(message);The following gives you the default message −console.log(message);The following gives you the warning message −console.warn(message);The following gives an information message −console.info(message);Add CSS to the log message −console.log('%c Add message!, "background: green; color: white;");Use the following to print error. Consider “num” as the variable name −console.error('num=%d', num);For complete API reference, refer Console API Reference.

How to set background image of a webpage?

Alankritha Ammu
Updated on 09-Sep-2023 23:37:45

29K+ Views

Beautiful webpages are a very strong means of catching user attention. In this article, we are going to see how we can add an image as the background image of a web. Approach There are two approaches to setting an image as the webpage's background image, which we will learn in this article. They are − Using background attribute Using CSS Method 1: Using background attribute We can use the background attribute in the body tag to set an image as the background of the webpage. We will need to specify the URL or the location of the image ... Read More

How to access cookies using document object in JavaScript?

Saurabh Jaiswal
Updated on 06-Jan-2023 12:58:06

6K+ Views

With JavaScript, you can easily access/ read cookies with the “document.cookie” property. Reading a cookie is just as simple as writing one because of the value of the document.cookie object is the cookie. The document.cookie string will keep a list of name=value pairs separated by semicolons, where the name is the name of a cookie and value is its string value. In this article, we will learn how to access cookies using document object in JavaScript. Syntax document.cookie Return value − All the cookies are saved in the browser in a single string. The document.cookie string will keep ... Read More

How do I print debug messages in the Google Chrome JavaScript Console?

Ali
Ali
Updated on 16-Jun-2020 13:35:05

198 Views

To print debug messages in the Google Chrome JavaScript Console, write a script, which is not creating console functions if they do not exist −if (!window.console) console = {}; console.log = console.log || function(){}; console.warn = console.warn || function(){}; console.error = console.error || function(){};Above you can see the following functions are used to log items based on a log, warn or info. It won’t cause errors when the console isn’t available. The following functions work in Google Chrome console −console.log( ); console.warn(); console.error();The Console object is used to access the browser's debugging console. As an example, consider the Web Console ... Read More

How to set cookies to expire in 30 minutes in JavaScript?

Prabhas
Updated on 09-Jan-2020 08:07:48

5K+ Views

You can extend the life of a cookie beyond the current browser session by setting an expiration date and saving the expiry date within the cookie. This can be done by setting the ‘expires’ attribute to a date and time.ExampleYou can try to run the following example to set cookies to expire in 30 minutesLive Demo                                                  Enter name:                    

How to print the content of JavaScript object?

Johar Ali
Updated on 16-Jun-2020 13:50:35

185 Views

To print content of JavaScript object, you can try to run the following code. Here, the object is created using the new keyword −ExampleLive Demo                          var dept = new Object();          dept.employee = "Amit";          dept.department = "Technical";          dept.technology ="C++";          document.getElementById("test").innerHTML =          dept.employee + " is working on " + dept.technology + " technology.";          

Advertisements