Skip to content
Advertisement

Tag: javascript

How can I move a div on scroll?

I have to move a div when the the user scrolls, but need to use pure JavaScript. position: fixed; will not work with the layout. The div’s original position is relative to something else. Is there a simple implementation using an event like onscroll, to detect how many pixels the page moved up or down, and change the position of

Improving regex for parsing YouTube / Vimeo URLs

I’ve made a function (in JavaScript) that takes an URL from either YouTube or Vimeo. It figures out the provider and ID for that particular video (demo: http://jsfiddle.net/csjwf/). It works, however as a regex Novice, I’m looking for ways to improve it. The input I’m dealing with, typically looks like this: 1) Right now I’m doing three separate matches, would

Why does the radix for JavaScript’s parseInt default to 8?

Defaulting the radix to 8 (if the string starts with a 0) in JavaScript’s parseInt function annoys me, only because I continue to forgot to pass the optional second argument as 10. I’m looking for an answer telling me why it makes sense to have it default to 8. Answer It only “defaults” to 8 if the input string starts

navigator.language list of all languages

Where i can see the list of languages and their codes? I want to compare languages and auto-select required language in template. Are they cross-browser equal? Any other solution? Answer This list of languages is defined by the ISO : http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes Example : be for belarus, fr for french. If you are looking for something more specific, those are not

Detect when a user leaves a website

I am trying to create my own website access library (for fun) like Google Analytics where I can detect when a user accesses my website, what pages they view etc. Is there a way to determine when the user leaves a page &/or leaves the website for good? I have successfully coded (in python) the detecting when the user 1st

JavaScript numbers to Words

I’m trying to convert numbers into english words, for example 1234 would become: “one thousand two hundred thirty four”. My Tactic goes like this: Separate the digits to three and put them on Array (finlOutPut), from right to left. Convert each group (each cell in the finlOutPut array) of three digits to a word (this what the triConvert function does).

Advertisement