87,992
社区成员
发帖
与我相关
我的任务
分享function LoadHref()
{
$('a').each(function()
{
var href = $(this).attr("href");
if(href.indexOf("index.php") > 0)
{
$(this).attr("href", "#/" + href.substr(href.indexOf("index.php") + 10));
$(this).attr("istrue", "1");
}
});
$(".page-navigator li a").click(function(){});
}
$('a').each(function()
{
var href = $(this).attr("href");
if(href.indexOf("index.php") > 0)
{
$(this).attr("istrue", "1");
var _this = $(this).replaceWith($(this.outerHTML.replace("index.php","#")));
// $(this).attr("href", "#/" + href.substr(href.indexOf("index.php") + 10));
}
});
var dhref = document.location.href;
function LoadHref()
{
$('a').each(function()
{
var href = $(this).attr("href");
if(href.indexOf("index.php") > 0)
{
$(this).attr("href", "#/" + href.substr(href.indexOf("index.php") + 10));
$(this).attr("istrue", "1");
}
});
$(".page-navigator li a").click(function(){});
}
function AjaxLoad(href)
{
if(href.length != "1")
{
$.ajax({
url: href,
// dataType: "html",
// async: false,
success:
function(data, textStatus, XMLHttpRequest)
{
$('#main').html(data);
LoadHref();
}
});
}
}
if(dhref.indexOf("#") >- 1)
{
dhref=dhref.replace("#", "index.php");
AjaxLoad(dhref);
}
$.address.init(function(event)
{
$("#nav-menu a").click(function()
{
$(this).addClass("current").siblings("a").removeClass("current");
});
LoadHref();
$('a[istrue == "1"]').address();
}).change(function(event)
{
var handler = function(data)
{
$('#main').html(data);
};
if(event.value != "/")
{
var href="/index.php" + event.value;
$.ajax({
url: href,
// dataType: "html",
// async: false,
error:
function(XMLHttpRequest, textStatus, errorThrown)
{
handler(XMLHttpRequest.responseText);
},
success:
function(data, textStatus, XMLHttpRequest)
{
handler(data);
LoadHref();
}
});
}
});
$(function()
{
$("#btns").click(function()
{
var text = $(this).attr("url");
var serach = $(this).attr("href", text + $("#stext").val() + "/");
AjaxLoad(serach);
});
});