Put the banner ads into an
<iframe> and use the
sandbox property of the iframe to limit its rights. But keep in mind that the sandbox property is not supported by Internet Explorer 9 and earlier, so these users will not be protected.
Also load your 3rd party content from a different subdomain than your own content. That way they don't get access to the cookies and localstorage of the main website (however, they do get access to any cookies set by other advertisers, unless you configure a different subdomain for every advertiser).