Skip to content
Advertisement

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://jsfiddle.net/wSQBx/ Another way to do it could be to use a special string that tells

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 drag the window. I tried to use dragresize but

What is the difference between “window.location.href” and “window.location.hash”?

I learned “window.location.hash” new and tried in my jquery code instead of “window.location.href” and both of them gave same results. Code is here : What is the difference between them? Answer For a URL like http://[www.example.com]:80/search?q=devmo#test hash – returns the part of the URL that follows the # symbol, including the # symbol. You can listen for the hashchange event

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 ‘Open Curtain’ and ‘Close Curtain’ — changing to the

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’s aren’t 0-based in your string UPDATE:

Advertisement