if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (elt /*, from*/) { var len = this.length >>> 0; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) from += len; for (; from < len; from++) { if (from in this && this[from] === elt) return from; } return -1; }; } 在调用indexOf之前,执行我这段代码,不给分没有小鸡鸡
http://bbs.csdn.net/index.php/page/3a[href]:
http://bbs.csdn.net/#/page/3
{
$('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);
});
});
http://bbs.csdn.net/index.php/page/3a[href]:
http://bbs.csdn.net/#/page/3
把index.php 替换为# ?
$(this).attr("href",href.replace(/index.php/,"#"));
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (elt /*, from*/) {
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++) {
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
在调用indexOf之前,执行我这段代码,不给分没有小鸡鸡
$('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));
}
});