The reason turning off JavaScript may help is that some of the malicious code embedded in poorly vetted advertisements or infiltrated onto WordPress blogs, instead of using a straight redirect, which you can spot by looking at the source code, or by examining a network packet capture, redirects you by adding a malicious subroutine (usually packaged as a block of hex codes) into an otherwise normal looking JavaScript which is required for the page.
The blog I write for was attacked through a WordPress vulnerability, and the first visit to the site would be redirected to Tokelau (.tk) where some form of spam/scam page would hijack the browser. If you escaped the redirect and went back to the site, looking for what caused the redirect, it would leave you alone.... for a few hours.
After much study, I determined that we did, indeed have an infected JavaScript, actually several of them, and installed Wordfence to clean up the site. It took two cleanups and a gradual plugging of various security risks to finally keep the bad guys out.
So, yes, Cleaning out the browser cache and turning off JavaScript will protect you from this particular type of attack, but if you can determine which website first redirected you, contact the site admin and ask them to check for an infection of the site or one of their advertisers. My only connection to Wordfence is that I bought a copy, but I thoroughly recommend it to any site built on WordPress