Skip to content

Author: admin@master

Detect touchpad vs mouse in Javascript

Is there any way to detect if the client is using a touchpad vs. a mouse with Javascript? Or at least to get some reasonable estimate of the number of users that use touchpads as opposed to mice? Answer In the general case, there is no way to do what you want. ActiveX might allow you to see and examine

Random alpha-numeric string in JavaScript?

What’s the shortest way (within reason) to generate a random alpha-numeric (uppercase, lowercase, and numbers) string in JavaScript to use as a probably-unique identifier? Answer If you only want to allow specific characters, you could also do it like this: Here’s a jsfiddle to demonstrate: http:/…

Use a child element to drag a parent element

I want to make something like navigation bar that can move whole element, without allowing dragging anywhere on the parent entire element to control the dragging. For example: Dragging on a title bar drags the whole window that it is contained within, but dragging elsewhere on the window container does not dr…

Changing button text onclick

When I click on myButton1 button, I want the value to change to Close Curtain from Open Curtain.HTML: Javascript: The button is displaying open curtain right now and I want it to change to close curtain, is this correct? Answer If I’ve understood your question correctly, you want to toggle between &#821…

How to parse a date in format “YYYYmmdd” in JavaScript?

This is a noob question: How to parse a date in format “YYYYmmdd” without external libraries ? If the input string is not in this format I would like to get invalid Date (or undefined if it will be easier). Answer Usage: UPDATE: As Rocket said, months are 0-based in js…use this if month&#821…