Open New URL from JQuery Tab

Posted on 2009-04-28
Medium Priority
Last Modified: 2012-05-06
Ok, I'm new to Javascript and even newer to JQuery, but am trying to learn both!

I have a webpage where I have implemented JQuery ui Tabs and they are working absolutely fine, using the default function shown below.

However, I have a real need to be able to open a new URL, using one of the tabs, however, I can't see how to do this. I'm sure it's possible, I just don't know how.

I understand I can use AJAX in a tab, but this solution won't work for me, I really need to be able to set the href of a tab to a normal URL and have it open as if the user had clicked on a bog standard link, ie in the existing window, not in a new window.

If anyone can help I'd be extermely grateful!
$(document).ready(function() {
	$(function() {

Open in new window

Question by:chuckalicious
LVL 16

Accepted Solution

anoyes earned 510 total points
ID: 24264784
I think the script below should work for you.  It'll open tabs that have a target="_blank" set on their <a> element in a new window.  The only catch is that you still have to precede the URL with a #.  So, for example, this would open in a new window:

<li><a href="#http://www.google.com/" target="_blank">Google</a></li>

whereas this would behave as usual:
<li><a href="#tab2">Tab 2</a></li>

<script type="text/javascript">
    select: function(event, ui) {
      if ($(ui.tab).attr('target') == '_blank')
        return false;

Open in new window


Author Comment

ID: 24556692
Ok, close enough. Your code still opens the link in a new window, which isn't what I'm looking for, however, I changed the code to the following. It now works nicely, so thanks :)


Open in new window


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question