Archive for 'Javascript'

Javascript select a div content

How to using a javascript command to select and deselect a div tag content? As I know, we can use a select() funtion to select text field value: document.getElementById(‘username’).select(); But the above example does not work for a div or span tag. For the div or span tag, it is pretty simply, just few lines […]

Dynamic wizard form using dhtml & javascript.

Recently I am working in a project that require some customization on the application. They need a wizard page that will allow user to add in items. To make the wizard page be more user friendly, I try to using dynamic html to create fields if required. When user add in a item, the page […]

Javascript string replace all

In PHP, str_replace will replace all the occurrence key in a string to the value that specified by user. In Javascript, if you using a replace function without specified, it will only replace the first occurrence of the key in the string to the value. For example : <script> var js_str = “Visit RedHat now […]

Detect & trigger action while user exit webpage

Some of website developers are need to track on visitor’s activity during browsing their website. Even would like to track when the visitor exit or quit their website. Below is a simple example on how to using a javascript command to track on visitor exit/close page action. (more…)