You were probably a victim of malvertising. Not directly 4chan's fault, but still partially their fault for partnering with advertisers who intentionally inject malware into their ads. Like >>93568
mentioned, get an adblocker and always be aware of what links you click. In the case of iframes, there's not much you can do because the malicious links typically take up a whole page, but others tend to use a dozen links that all say something top the effect of "DOWNLOAD NOW" or "CLICK HERE TO BEGIN" and bury the legit links.