I need to transform url from /page#id to /page when refreshing the page. I'm using window.location.href = window.location.href to refresh. Any solutions? should I combine if with other function?
Use slice like: //your url my_url = 'http://www.my_site.com/page#9'; //the last index of the # sign b = my_url.lastIndexOf('#'); //slicing from 0 (begining of string) to b (the # sign) new_url = my_url.slice(0,b); //output should be http://www.my_site.com/page Code (markup): Cheers!