Javascript with detect