Heads up! This blog post hasn't been updated in over 2 years. CodePen is an ever changing place, so if this post references features, you're probably better off checking the docs. Get in touch with support if you have further questions.

We used to go to some elaborate trouble to allow you to use target="_blank" on anchor links within our sandboxed iframe. We're not sure if it was a behavior change in browsers or if it was something we changed over time regarding sandboxing or other security measure, but now, target="_blank" links work as expected in previews: they open links in a new window/tab.

One of the big side-benefits here, is that we got to strip out that extra JavaScript code we were having to inject into previews to make this work. It was a cause of a good amount of confusion because of the way browser rendering works. If you had code like this:


  var yep = "you'll see this.";

You'd literally see the contents of that script being rendered, because of the weirdly unclosed div tag. We got plenty of confused support requests about that, since we don't make any judgements about your HTML before rendering it, you would occasionally see our injected script if you had unclosed HTML. Now that's only a problem if you author your own JavaScript, but at least you'll recognize it.