【发布时间】:2011-07-29 08:39:07
【问题描述】:
我确实有一个进行某种管理的网站。在那里,我使用 JQuery Tab 作为结构并使用 AJAX 调用所有面板。根据我在某处找到的帖子,我还使用 JQuery 地址作为书签
我有两个问题
1) 虽然这一切都适用于 FF,但我无法让它在 IE 中运行(嗯,只是书签的东西) 2) 我的 javascript 看起来很糟糕(我不知道如何简化它)
你能帮上忙吗?
谢谢
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>title</title>
<link type="text/css" href="Style/style.css" rel="stylesheet"/>
<link href="Style/jquery-ui.css" rel="stylesheet" type="text/css"/>
<link href="Style/colorbox.css" rel="stylesheet" type="text/css"/>
<script src="JS/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="JS/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
<script src="JS/jquery.address-1.3.1.min.js" type="text/javascript"></script>
<script src="JS/jquery.colorbox-min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("a[rel='colorBox']").colorbox();
$(".tabs1").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{
$(".tabs1").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs2").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs3").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs2").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs3").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
});
$(function(){
var title = 'title';
$('head title').text(title);
// jQuery Address
$.address.strict(0);
$.address.tracker(0);
if ($.address.value() == '') {
$(".tabs1").tabs("select", "#index");
//$(".tabs2").tabs("select", "#list");
$.address.value('index');
}
$.address.init(function(event) {
$(".tabs1").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{
$(".tabs1").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs2").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs3").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs2").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
$(".tabs3").tabs( {
ajaxOptions: {
error: function( xhr, status, index, anchor )
{ $( anchor.hash ).html("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. ");
},
success: function()
{ $(".tabs1").tabs(); $(".tabs2").tabs(); $(".tabs3").tabs();
$(".ajaxColorBox").colorbox({width:"75%", height:"75%"});
$(".ajaxColorBoxLabel").colorbox();
$(".ajaxColorBoxForm").colorbox({width:"75%", height:"75%",inline:true, href:"#inline_form"});
$(".ajaxColorBoxiFrame").colorbox({width:"75%", height:"75%",iframe:true,onClosed:function(){ location.reload(true); }});
$('ul li a').bind('click', function()
{
var value = $(this).attr('href').substring(1); $.address.value(value);
});
}
} } );
});
$.address.change(function(event) {
var value = $.address.value();
$.address.title(title + ' @ #' + value);
});
$.address.externalChange(function(event) {
var value = $.address.value();
var value_array = value.split('-');
$(".tabs1").tabs("select", value_array[0]);
$(".tabs2").tabs("select", value_array[1]);
$(".tabs3").tabs("select", value_array[2]);
$.address.value(value);
});
$.address.history(true);
$('ul li a').bind('click', function() {
var value = $(this).attr('href').substring(1);
$.address.value(value);
});
});
</script>
</head>
<body>
<div class="tabs1">
<ul>
<li><a href="indexTab.php" title="index"><span>Home</span></a></li>
<li><a href="memberTab.php" title="member"><span>Données membre</span></a></li>
<li><a href="clubTab.php" title="club"><span>Club</span></a></li>
<li><a href="gestionTab.php" title="gestion"><span>Gestion</span></a></li>
<li><a href="toolsTab.php" title="tools"><span>Outils</span></a></li>
</ul>
<div id="index" class="ui-tabs-hide"></div>
<div id="member" class="ui-tabs-hide"></div>
<div id="club" class="ui-tabs-hide"></div>
<div id="gestion" class="ui-tabs-hide"></div>
<div id="tools" class="ui-tabs-hide"></div>
</div>
</body>
</html>
【问题讨论】:
-
那是很多代码。你能在jsfiddle.net 创建一个例子吗?
标签: jquery ajax tabs nested bookmarks