Usharani has Published 93 Answers

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

usharani

usharani

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

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 ... Read More

How to call a JavaScript function from an onsubmit event?

usharani

usharani

Updated on 16-Jun-2020 11:37:14

The onsubmit event occurs when you try to submit a form. You can put your form validation against this event type. The following example shows how to use onsubmit. Here, we are calling a validate() function before submitting a form data to the webserver. If validate() function returns true, the ... Read More

What are Java parent and child classes in Java?

usharani

usharani

Updated on 16-Jun-2020 08:47:34

Java supports inheritance, an OOPs concept where one class acquires the members (methods and fields) of another.You can inherit the members of one class from another, use the extends keyword as:class A extends B{}The class which inherits the properties of other is known as child class (derived class, sub class) ... Read More

How to use labels in Java code?

usharani

usharani

Updated on 16-Jun-2020 06:29:04

Java provides two types of branching/control statements namely, break and continue.The break statementThis statement terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.ExampleFollowing is the example of the break statement. Here we are trying to print elements up to 10 and, ... Read More

How to programmatically empty browser cache with HTML?

usharani

usharani

Updated on 01-Jun-2020 10:53:08

You can tell your browser not to cache your page by using the following meta tags −<metahttp-equiv = 'cache-control' content = 'no-cache'> <metahttp-equiv = 'expires' content = '0'> <metahttp-equiv = 'pragma' content = 'no-cache'>In addition, try the following:  Append a parameter/string to the filename in the script tag. Change it ... Read More

Execute a script when a user navigates to a page in HTML?

usharani

usharani

Updated on 01-Jun-2020 09:12:30

Use the onpageshow attribute to execute a script when a user navigates to a page.ExampleYou can try to run the following code to implement onpageshow attribute −<!DOCTYPE html> <html>    <body onpageshow = "display()">       <h2>Tutorialspoint</h2>       <p>Simply Easy Learning</p>       <script>         ... Read More

Execute a script when a mouse pointer moves over an element in HTML?

usharani

usharani

Updated on 30-May-2020 23:25:36

The onmouseover attribute triggers when a mouse pointer moves over an element in HTML.ExampleYou can try to run the following code to implement onmouseover attribute −<!DOCTYPE html> <html>    <body>       <h3 id = "myid" onmouseover = "display()">          This is demo heading.       </h3> ... Read More

How to use multiple click event on HTML5 canvas?

usharani

usharani

Updated on 04-Mar-2020 06:13:50

When there is a circle drawn on canvas and we put red color on half and grey color on a portion of a circle, then on clicking a red color, we call function1.On clicking grey part, function 2 is called and we need to use reusable path objects to store ... Read More

Change text color based on a brightness of the covered background area in HTML?

usharani

usharani

Updated on 04-Mar-2020 05:03:50

It is possible to change the textcolour depending on the average brightness of the covered pixels ofits parent's background color by using the following code snippet.var rgb = [255, 0, 0]; setInterval(display, 1000); function display() {    rgb[0] = Math.round(Math.random() * 255);    rgb[1] = Math.round(Math.random() * 255);    rgb[2] ... Read More

Bootstrap dropdown closing when clicked in HTML

usharani

usharani

Updated on 04-Mar-2020 05:03:11

As you may have seen, whenever you open a dropdown, and click anywhere else, the dropdown close. By using the below given code, the dropdown menu can be kept open after click−$('#myDropdown').on('hide.bs.dropdown', function () {    return false; });Another option is to handle the clickevent −The click event can also be ... Read More

Advertisements