Fix javascript errors when working in a page opened with taget="_blank"