Fixed javascript url generate function