2011-05-05 78 views
0

我为我的网站创建了jquery选项卡。我在其中一个选项卡的内容中有一些应用程序按钮。当我点击其中一个按钮(这些按钮包含不同的链接)时,它将带我离开我的标签页并打开另一页中的内容。我不想那么做,我需要做什么?jquery选项卡问题

+2

代码。向我们展示代码。 – 2011-05-05 15:17:29

+0

你希望**链接打开的位置?链接是否连接到您自己的域上的URL? – 2011-05-05 15:18:11

+4

你好!由于我看到你对这个网站是新手,我只是想给你一个指示,帮助你更好地回答你的问题。首先,请提供源代码(尽量保持简单和小巧),以展示您的问题。不幸的是,我们无法调试我们看不到的代码。 – JasCav 2011-05-05 15:19:00

回答

1

您需要在

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

// Code to run goes here... 

Return False // - Stops the link from firing 
} 

或使用jQuery你可以做的preventDefault添加...

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

// code here... 

e.preventDefault(); 
} 
+0

这些按钮位于报表查看器中webpart – bobo 2011-05-05 15:23:31

+1

我认为您可能需要发布一些代码伴侣。 – 2011-05-05 15:24:29

+0

我的代码在这里:http://stackoverflow.com/questions/5872315/jquery-tabs-problem – bobo 2011-05-05 15:29:40

0
<!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> 
+0

显然更改您的网址的网址,但这会预先加载iframe src,然后再单击选项卡... – 2011-05-05 15:40:46