working js function for url