做网站经常会用到的一些js效果
2017-11-27 10:54
429 查看
1.返回顶部
$(function(){
$('.top').hide();
$(window).scroll(function() {
if($(window).scrollTop() >= 100){
$('.top').fadeIn(300);
}else{ $('.top').fadeOut(300); }
});
$('.top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);});
});
2.点击锚点移动到对应的位置
$(".aa").click(function(event){
event.preventDefault(); //取消事件的默认动作。
$('html,body').animate({scrollTop:$(this.hash).offset().top},800);
});
3.判断页面加载是否完成
document.onreadystatechange = loadingChange;//当页面加载状态改变的时候执行这个方法.
function loadingChange() {
if(document.readyState == "complete"){ //当页面加载状态为完全结束时进入
$(".loading").hide();//当页面加载完成后将loading页隐藏
window.location.href="http://www.baidu.com";
}
}
4.禁止鼠标右键
$(document).ready(function(){
$(document).on("contextmenu",function(e){
return false;
});
});
5.判断是pc端还是移动端
function getClientInfo(){
var banner=document.getElementById('banner');
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var agentinfo = null;
for (var i = 0; i < Agents.length; i++) {
if (userAgentInfo.indexOf(Agents[i]) > 0) { agentinfo = userAgentInfo; break; }
}
if(agentinfo){
$('.banner').css('height','auto');
banner.style.height='auto'
}else{
$('.banner').css($(window).height());
banner.style.height=document.body.clientHeight
}
}
6.判断是否是ie浏览器
function isIE() { //ie?
if (!!window.ActiveXObject || "ActiveXObject" in window){
return true;
}else{}
return false;
}
$(function(){
$('.top').hide();
$(window).scroll(function() {
if($(window).scrollTop() >= 100){
$('.top').fadeIn(300);
}else{ $('.top').fadeOut(300); }
});
$('.top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);});
});
2.点击锚点移动到对应的位置
$(".aa").click(function(event){
event.preventDefault(); //取消事件的默认动作。
$('html,body').animate({scrollTop:$(this.hash).offset().top},800);
});
3.判断页面加载是否完成
document.onreadystatechange = loadingChange;//当页面加载状态改变的时候执行这个方法.
function loadingChange() {
if(document.readyState == "complete"){ //当页面加载状态为完全结束时进入
$(".loading").hide();//当页面加载完成后将loading页隐藏
window.location.href="http://www.baidu.com";
}
}
4.禁止鼠标右键
$(document).ready(function(){
$(document).on("contextmenu",function(e){
return false;
});
});
5.判断是pc端还是移动端
function getClientInfo(){
var banner=document.getElementById('banner');
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var agentinfo = null;
for (var i = 0; i < Agents.length; i++) {
if (userAgentInfo.indexOf(Agents[i]) > 0) { agentinfo = userAgentInfo; break; }
}
if(agentinfo){
$('.banner').css('height','auto');
banner.style.height='auto'
}else{
$('.banner').css($(window).height());
banner.style.height=document.body.clientHeight
}
}
6.判断是否是ie浏览器
function isIE() { //ie?
if (!!window.ActiveXObject || "ActiveXObject" in window){
return true;
}else{}
return false;
}
相关文章推荐
- 做网站经常会用到的一些js效果
- 做网站经常会用到的一些js效果
- js一些工作中经常用到的脚本
- 整理一些经常用到的js代码(一) 不断更新中。。。
- 收藏的25个非常有用的CSS代码片段,在你开发基于CSS的网站时,这些代码是经常用到的,比方说一些特殊的效果,圆角边框,CSS透明度,梯形环绕,CSS小三角等,希望对你有用
- js验证表单(都是一些经常要用到的)
- 一些经常会用到的原生JS方法
- 经常用到的一些js方法
- [置顶] 前段开发 一些经常用到的js插件
- JS 注册经常用到的效果
- JS-拖拽里面经常用到的函数
- git 经常用到的一些命令
- 类库-----一些经常用到的对控件的处理1. 获取文本框中输入内容2.清除文本框内容3. 获取下拉列表框中选择内容,类型0为Text值,类型1为Value值4.DropDownList绑定日期
- 经常用到的一些网址
- [docker]一些经常用到的docker容器启动方法
- 一些經常用到的js驗證代碼
- 整理一些我经常用到的函数吧(不断更新)
- word应用中一些不经常用到的功能
- 记录一些长用到的js方法
- 一些平时能用到的CSS效果(ZT+YC)