左側和頭部的導航滑動欄css
$(function () {
if (navigator.platform.indexOf('Win32') != -1) {
var btop = parseInt($('#myTab').offset().top);
var statich = parseInt($('#myTab').css('height'));
var daytabtop = parseInt($('#daytab').offset().top);
var daytabhidelength = parseInt($('#myTabContent').css('height'));
var number = $('#daytab').children('li').length;
var alllength = 0;
var clonemyTab = $('#myTab').clone();
clonemyTab.attr("id", "myTabClone");html
$('#daytab').children('li').each(function () {
var divindex = parseInt($(this).index() + 1);
if ($("#day" + divindex).length) {
if (!isNaN(parseInt($("#day" + divindex).css('height')))) {
alllength += parseInt($("#day" + divindex).css('height'));
}
}
})api
$(window).scroll(function () {
var hidelength = parseInt($('#myTabContent').css('height'));
var isIE = !-[1, ];
var isIE6 = isIE && !window.XMLHttpRequest;
if (isIE6) { return false; }
if (document.documentElement && document.documentElement.scrollTop) {
var newtop = document.documentElement.scrollTop;
} else {
var newtop = document.body.scrollTop;
}
if (newtop >= btop) {
if (!$("#myTabClone").length) {
$('#myTab').parent().prepend(clonemyTab);
}
$('#myTab').css('position', 'fixed'); $('#myTab').css('top', '0px');
} else {
if ($("#myTabClone").length) {
$('#myTabClone').remove();
}
$('#myTab').css('position', 'static');
}
if (newtop >= daytabtop && newtop <= (daytabtop + alllength - statich)) {
$('#daytab').css('position', 'fixed'); $('#daytab').css('top', '0px'); $('#daytab').children("li").css('float', 'none');
} else {
$('#daytab').css('position', 'static');
}cookie
$("[data-tourl]").each(function () {
var urlat = $(this).attr("data-tourl");
var toprourl = parseInt($(this).offset().top);app
if (newtop >= (toprourl - statich-1)) {
$('#myTab').children('li').removeClass("active");
$("[data-url='" + urlat + "']").parent().addClass("active");
}
})async
$('#daytab').children('li').each(function () {
var divindex = parseInt($(this).index() + 1);
var divtop;
if ($("#day" + divindex).length) {
divtop = parseInt($("#day" + divindex).offset().top);
}ide
if (newtop >= (divtop - statich)) {
$('#daytab').children('li').removeClass("active");
$(this).addClass("active");
}
})
});ui
/*點擊頭部導航跳轉*/
$('#myTab li a').click(function () {
var tourl = $(this).attr("data-url");
if ($("[data-tourl='" + tourl + "']").length) {
var htop = parseInt($("[data-tourl='" + tourl + "']").offset().top);
}
$('#daytab').children('li').removeClass("active");
$('#daytab').children('li:eq(0)').addClass("active");this
$('#myTab').css('position', 'fixed'); $('#myTab').css('top', '0px');
$("html,body").animate({ scrollTop: (htop - statich) }, 0);
})url
/*點擊左側導航跳轉*/
$('#daytab').children('li').click(function () {
var divindex = parseInt($(this).index() + 1);
var divtop;
if ($("#day" + divindex).length) {
divtop = parseInt($("#day" + divindex).offset().top);
}
$('#myTab').css('position', 'fixed'); $('#myTab').css('top', '0px');
$("html,body").animate({ scrollTop: (divtop - statich) }, 0);
})
}
})
facebook聯合登陸
function statusChangeCallback(response) { if (response.status === 'connected') { var accessToken = response.authResponse.accessToken; console.log(accessToken); FB.api('/me?fields=name,first_name,last_name,email', function(response) { console.log(response); if(accessToken&&response.email){ }else { alert("Longin failed!Please retry again1."); } }); }}facebookLogin=function(){ FB.login(function(response){ FB.getLoginStatus(function(response) { statusChangeCallback(response); }); },{scope:'email'});}window.fbAsyncInit = function() { FB.init({ appId : 'youid', cookie : true, xfbml : true, version : 'v2.8' });};// Load the SDK asynchronously(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));