Found 6710 Articles for Javascript

How to create domain-based cookies using JavaScript?

Anvi Jain
Updated on 16-Jun-2020 11:58:59

349 Views

To create a domain-based cookie, set the domain and path attribute on your cookie, like −domain=.example.comExampleYou can try to run the following code to learn how to create domain-based cookies −Live Demo                                                  Enter name:                    

How to use JavaScript to set cookies for multiple pages?

Nitya Raut
Updated on 16-Jun-2020 11:57:22

1K+ Views

To set cookies for multiple pages, you need to set the path as −;path=/ExampleThe above will make your cookies to site cookie. You can try to run the following code to set cookies for multiple pages −Live Demo                                                  Enter name:                    

What is the maximum value represented by Number object in JavaScript?

Smita Kapse
Updated on 17-Jun-2020 06:20:45

312 Views

The largest possible value a number in JavaScript can have 1.7976931348623157E+308. The Number.MAX_VALUE property belongs to the static Number object. It represents constants for the largest possible positive numbers that JavaScript can work with.ExampleYou can try to run the following code to get the maximum value represented by Number object −Live Demo                                         Click the following to see the result:                          

How to use JavaScript to set cookies for a specific page only?

Abhishek Kumar
Updated on 21-Sep-2022 07:58:57

2K+ Views

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. Something so trivial as this is a user preference and thus can be conveniently stored in a corresponding cookie file. The pathname property of the Window location returns a string containing the path of the current webpage. The path is basic information about ... Read More

How to use JavaScript to set cookies for homepage only?

Vrundesha Joshi
Updated on 09-Jan-2020 10:33:42

329 Views

To set cookies for a homepage, add the page to the homepage itself.ExampleYou can try to run the following code to set cookiesLive Demo                                                  Enter name:                    

How to list down all the cookies by name using JavaScript?

Rishi Rathor
Updated on 09-Jan-2020 10:32:39

269 Views

To lists down all the cookies by name, use the cookies pairs in an array. After that, you need to get the key value pair out of this array.ExampleYou can try to run the following code to list all the cookiesLive Demo                                                   click the following button and see the result:                    

What are JavaScript Native Objects?

Shubham Vora
Updated on 15-Nov-2022 10:44:56

4K+ Views

In this tutorial, we will learn about native objects in JavaScript. Native JavaScript objects are regular JavaScript objects offered by JavaScript itself. Inbuilt objects, pre-defined objects, and global objects are other names. No matter the computer or environment, all users have access to these objects, and they function similarly. They may be used as both constructors (like String(), Array(), and Object()) and primitive values since their functions are unaffected by changes to the machine or environment. An object in an ECMAScript implementation whose semantics are entirely determined by this specification as opposed to the host environment. Native objects are additionally ... Read More

How to simulate a keypress event in JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 08:05:35

7K+ Views

We use event handlers to simulate keypress events in JavaScript. An event in JavaScript, as the name suggests, refers to actions taken by the browser or user. An event handler is a utility that JavaScript provides, that lets the programmer implement the correct course of response to those events. We will be using the jQuery library to simulate keypress events in JavaScript. It is a library for JavaScript to traverse HTML documents as well as manipulate them, create animations, and much more. One such feature is event handling that we will be using. Event An Event is a change that ... Read More

How to use the 'with' keyword in JavaScript?

Nitya Raut
Updated on 17-Jun-2020 06:14:29

6K+ Views

The with keyword is used as a kind of shorthand for referencing an object's properties or methods.The object specified as an argument to with becomes the default object for the duration of the block that follows. The properties and methods for the object can be used without naming the object.SyntaxThe syntax for with object is as follows −with (object){    properties used without the object name and dot }ExampleYou can try to learn the following code to learn how to implement with keyword −Live Demo           User-defined objects               ... Read More

What are secured cookies in JavaScript?

Daniol Thomas
Updated on 30-Jul-2019 22:30:21

2K+ Views

A secured cookie is a cookie that works with HTTP/HTTPS, known as a httpOnly cookie. These cookies are only used for HTTP requests, so unethical access though scripting is not possible. Therefore, cross-site scripting can be stopped, which in turn stops attacks.The secure attribute is always activated for secured cookies, so it is transmitted with encrypted connections, without any hassles and security issues. The httpOnly flag does not give cookie access to JavaScript or any non-HTTP methods. This is situated in the secure cookie header.The secure attribute and httpOnly flag ensure that the browser does not allow malicious scripts to ... Read More

Advertisements