Quick: Dynamically Open External Links in a New Window
Since I began writing HTML ten years ago, I hated using target=“blank” in my markup. Coupled with the fact that if you’re using a strict DOCTYPE the target method is invalid anyway, I began looking for an easy way to open only external links in a new window (and I realize there are pros and cons of doing this). Using this jQuery technique, each link is tested to check if it’s local or not, or alternatively in the second method only opening links in a new window if they are children of a given element.



