Category: Javascript

Nowadays all modern browsers allow copying content to the clipboard with JavaScript.

But before this, it is not supported in most browsers because of security reasons. You need to ask the user to press CTRL+C to copy the currently selected text.

The ZeroClipboard library uses invisible Adobe Flash movie to copying content to Clipboard. It works well with most browsers.

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

How to copying content to the Clipboard with JavaScript

How To Javascript

In this tutorial, I show How you can check whether an Array already contains a specific value or not.

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 the particular value.
  • etc.

If you are familiar with PHP, where you can use the in_array() function to search value in the Array and its 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.

Javascript Jquery

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 in 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 in the websites or PTC sites which provide ads viewing to the users. They only count the ads view when the user is active on their website until 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

Javascript Jquery

Javascript

for-in is an another type of looping statement within JavaScript. Which works similarly like a foreach loop in PHP.

When performing iteration with for-in then it returns key on each iteration.

It works with both –

  1. Array and
  2. Object

for-in loop in JavaScript

Javascript

Did you ever thought to make an editable div element or <p>, <span>, etc. that works same like a Text field and Textarea.

Some websites allow the user to edit their content by just pointing to the content and start to update it.

You will already know that <div> is a read-only container that means you can’t edit the content inside of it.

In this tutorial, I show how you can do this with the contentEditable attribute.

How to make editable div element with contentEditable attribute

How To Javascript

If you are familiar with PHP where for reading parameters from URL you can use either $_GET or $_REQUEST which take the name of the argument and return value of it.

In the JavaScript, there is no direct way to read arguments from URL like in PHP you need to do some work for getting it.

In this tutorial, I show how you can read and extract parameters with JavaScript.

Read and Get Parameters from URL with JavaScript

Javascript

Password field by default doesn’t show any visible text other than the symbol.

Some websites allow the user to view the hidden text in password field by toggling.

For this, they provide an element e.g. checkbox or a button when it gets clicked then the password element value is been visible on the screen and reset to default view when it again gets clicked.

In this article, I show How you can implement this functionality with jQuery and JavaScript.

show and hide Password field text with jQuery and JavaScript

Javascript Jquery

You cannot control when user will refresh the web page and close it, but it’s important sometimes to display confirmation alert before closing the Tab.

The user may be mistaken clicked the close button and lost some important data.

You have seen in Shopping websites when you are in the middle of payment or you are paying the Bill and if you try to refresh the web page then it will show a confirm alert on the screen.

When is it Required?

  • When the form has many fields and the user filled the form but somehow the Browser is being closed. Now, the user needs to again fill that long form.
  • While student giving the online test and not completed yet and try to close or refresh the page.
  • There are many other situations where you can use it.

In this post, I discuss How you can detect Browser Tab close and refresh using JavaScript.

How to know a browser tab close or refresh with JavaScript

Javascript

Twitter only allows maximum 140 characters of a tweet. At the time of entering input, it shows how many characters are remaining.

Remaining character value changes on every character input.

Similar to Twitter other websites also uses the same functionality.

For example – In the medium, you could see this in Bio section there it allows 160 character input after that it didn’t take any inputs.

In this tutorial, I am creating the similar type of functionality with jQuery.

Twitter like remaining character count using jQuery

Javascript Jquery