How to copying content to Clipboard with JavaScript

Numerous we­b applications require the ability to copy conte­nt easily, for a variety of purposes such as note­-taking, code snippet repositorie­s, and social media sharing tools. Copying text or data through a simple click on the­ clipboard in today’s digital landscape is an essential fe­ature.

In the pre­sent-day scenario, most modern browse­rs offer an effortless way to copy conte­nt to the clipboard utilizing JavaScript.

Before­ proceeding, it is worth noting that due to se­curity protocols, this feature may not be compatible­ with several browsers. To copy the­ selected te­xt, kindly instruct the user to press CTRL+C shortcut command.

In this tutorial, I show how you can copy the content to the clipboard with or without plugins.

How to copying content to Clipboard with JavaScript

Read more

Restrict keyboard character input with jQuery

It is better to restrict the user from entering invalid input and submit the form.

If the inputted data is invalid then the request is not been executed on the server-side script if added validation and the user needs to again fill the details.

If a field does not require a specific type value like – number, character, special character then stop the user from entering.

In this tutorial, I show how you can restrict keyboard character input with jQuery and JavaScript.

Restrict keyboard character input with jQuery

Read more

Check if value exists in Array – jQuery and JavaScript

In this tutorial, I show how you can check whether an Array already contains a specific value or not using Javascript and jQuery.

This requires within the program in some cases like –

  • Stop new value from insert if it already exists in an Array.
  • Execute script when the Array contains a particular value.
  • etc.

If you are familiar with PHP, where you can use the in_array() function to search value in the Array, and it returns the Boolean value ( TRUE or FALSE ).

There are inbuilt methods in jQuery and JavaScript that return the index position of the value which you can use for the search.

Check if value exists in Array – jQuery and JavaScript

Read more

How to Detect Browser Window is Active or not – JavaScript

Sometimes you may want to take more control over your user Browser when he/she opens your website in a Browser Window.

For example – you want to know when the user closes the Browser Tab and execute your code.

If you want to know how much time the user active on your website, in this case, you can use JavaScript. Using that you only enabled the timer when the user is an active tab on your website.

Or you want to run the Animation only when the user is active otherwise stop it.

This kind of functionality you have seen on websites or PTC sites that provide ads viewing to the users. They only count the ads view when the user is active on their website until a given time otherwise they cancel the view after the specific time.

In this tutorial, I show how you can use JavaScript to detect whether Browser Tab Window is active or not.

How to Detect Browser Window is Active or not - JavaScript

Read more