Radhakrishna has Published 93 Articles

What is onkeypress event in JavaScript?

radhakrishna

radhakrishna

Updated on 19-Jun-2020 11:18:13

230 Views

The onkeypress event triggers when a key is pressed and released. You can try to run the following code to learn how to work with onkeypress event in JavaScript −Example                                            

How to calculate the area and perimeter of a circle in JavaScript?

radhakrishna

radhakrishna

Updated on 19-Jun-2020 08:46:31

707 Views

To calculate the area and perimeter of a circle, you can try to run the following code −Example           JavaScript Example                        function Calculate(r) {             this.r = r;   ... Read More

How do we upload external file on a website using HTML forms?

radhakrishna

radhakrishna

Updated on 17-Jun-2020 13:25:16

5K+ Views

If you want to allow a user to upload an external file to your website, you need to use a file upload box, also known as a file select box. This is also created using the element but type attribute is set to file.ExampleLive DemoYou can try to run ... Read More

Abstraction vs Encapsulation in Java

radhakrishna

radhakrishna

Updated on 17-Jun-2020 07:32:57

739 Views

EncapsulationEncapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction.Encapsulation in Java is a mechanism for wrapping the data (variables) and code acting on the data (methods) together as a single unit. In encapsulation, the variables of a class will be hidden from ... Read More

method overloading and type promotion in Java

radhakrishna

radhakrishna

Updated on 17-Jun-2020 06:54:02

958 Views

Method overloading helps to create multiple methods with the same name to do similar action on a different type of parameters.We can use type promotion in case variables are of similar type. Type promotion automatically promotes the lower range value to higher range value. For example, byte variable can be ... Read More

How to set cookies expiry date in JavaScript?

radhakrishna

radhakrishna

Updated on 16-Jun-2020 11:46:10

4K+ Views

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 the expiry date ... Read More

Why should we use a semicolon after every function in JavaScript?

radhakrishna

radhakrishna

Updated on 16-Jun-2020 11:41:07

664 Views

Adding semicolons after every function is optional. To avoid undesirable results, while using functions expressions, use a semicolon.Using semicolonvar display = function () {   alert(“Hello World”); }; (function () {   // code })();Without using semicolonvar display = function () {   alert(“Hello World”); } (function () {   // code })();The first function executes immediately since we have used the semicolon.

How can I convert Python dictionary to JavaScript hash table?

radhakrishna

radhakrishna

Updated on 05-Mar-2020 07:13:01

934 Views

Python and javascript both have different representations for a dictionary. So you need an intermediate representation in order to pass data between them. The most commonly used intermediate representation is JSON, which is a simple lightweight data-interchange format.The dumps function converts the dict to a string. exampleimport json my_dict = { ... Read More

How to save HTML Canvas as an Image with canvas.toDataURL()?

radhakrishna

radhakrishna

Updated on 04-Mar-2020 04:47:58

653 Views

Use toDataURL() method to get the image data URL of the canvas. It converts the drawing (canvas) into a64 bit encoded PNG URL.ExampleYou can try to run the following code to save the canvas as an image −                     ... Read More

Execute a script when the browser is in the process of getting the media data in HTML?

radhakrishna

radhakrishna

Updated on 03-Mar-2020 12:33:46

56 Views

Use the onprogress attribute to execute a script when the browser is in the process of getting the media data in HTML.ExampleYou can try to run the following code to implement onprogress attribute −                                        Your browser does not support HTML5 video.                      function display() {             alert("Started");          }          

Previous 1 ... 3 4 5 6 7 ... 10 Next
Advertisements