bobo
bobo

Reputation: 47

jquery tabs question

I created jquery tabs for my website. I have some application buttons inside the content of one of my tabs. When I click on one of the buttons (these buttons contains different links) it takes me away from my tab page and opens the content in another page. I do not want that so what do i need to do?

Upvotes: 0

Views: 275

Answers (2)

Chris Dowdeswell
Chris Dowdeswell

Reputation: 868

<!DOCTYPE html>
<html>
<head>
<META name="WebPartPageExpansion" content="full">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

  <script>
  $(document).ready(function() {
    $("#frame-1").attr("src","http://www.google.com");
    $("#frame-2").attr("src","http://www.google.com");
    $("#frame-3").attr("src","http://www.google.com");
    $("#frame-4").attr("src","http://www.google.com");
    $("#tabs").tabs();
  });
  </script>
</head>
<body style="font-size:62.5%;">

<div id="tabs">
    <ul>
            <li><a href="#tabs-1">site1</a></li>
            <li><a href="#tabs-2">site2</a></li>
            <li><a href="#tabs-3">site3</a></li>
            <li><a href="#tabs-4">site4</a></li>
      </ul>
            <div id="tabs-1">
            <iframe id="frame-1" src="http://www.facebook.com" width="100%" height="500">
            <p>Your browser does not support iframes.</p> </iframe>
            </div>
    <div id="tabs-2">
            <iframe src="http://www.google.com" id="frame-2" width="100%" height="500">
            <p>Your browser does not support iframes.</p></iframe>  
    </div>
    <div id="tabs-3">
            <iframe src="url3" width="100%" id="frame-3" height="500">
            <p>Your browser does not support iframes.</p></iframe>  
    </div>
    <div id="tabs-4">
            <iframe  src="url4" id="frame-4">
            <p>Your browser does not support iframes.</p></iframe>  
    </div>



</div>
</body>
</html>

Upvotes: 0

Chris Dowdeswell
Chris Dowdeswell

Reputation: 868

You need to add in

$(".btn").click(function() {

// Code to run goes here...

Return False // - Stops the link from firing
}

or using jquery you can do preventDefault...

$(".btn").click(function(e) {

// code here...

e.preventDefault();
}

Upvotes: 1

Related Questions