implement page title code in JS