jQuery Load New Window

By Sam Deering

jQuery code snippet to load/open a link in new window. This code adds an event to the anchor tags that are given the “new-window” class and forces them to open in a new window.

 return false;

Advanced jQuery Load New Window Example

This code gets the id of a container div and then grabs the hidden url div element and then opens it in a new window.

function openblog(blog_id) {
	var blogurl = $('#'+blog_id+'-url').text();
	var location = "http://domainname/index.php?blogurl="+blogurl;;

The HTML Code

No Reader comments



Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in JavaScript, once a week, for free.