$(function(){ if(!placeholdersupport()){ $('[placeholder]').focus(function() { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeclass('placeholder'); } }).blur(function() { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addclass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); }; if(!ispc()){$('body').addclass('touch_body')} //ie浏览器 if(isie()){$('html').addclass('isie');} // 获取当前url var url_location = window.location.pathname; var arr = []; arr = url_location.split('/'); }) function placeholdersupport() { return 'placeholder' in document.createelement('input'); } function scrollt($dom){ if($dom.offset()){ if($(window).scrolltop()+$(window).height()>=$dom.offset().top+200){ return true; } } } function mainbgresize1($img, width, height, w_b, h_b) { var sw = width, sh = width / w_b * h_b if (sh < height) { sh = height; sw = height / h_b * w_b } $img.css({height:sh,width:sw, margintop: -(sh - height) / 2, marginleft: -(sw - width) / 2, 'visibility': 'visible' }); } //判断是否firefox浏览器 function isfirefox(){ if (navigator.useragent.indexof("firefox") > -1) return true; else return false; } //判断是否ie浏览器 function isie() { if (!!window.activexobject || "activexobject" in window) return true; else return false; } function ispc() { var useragentinfo = navigator.useragent; var agents = new array("android", "iphone", "symbianos", "windows phone", "ipad", "ipod"); var flag = true; for (var v = 0; v < agents.length; v++) { if (useragentinfo.indexof(agents[v]) > 0) { flag = false; break; } } return flag; } //绑定事件监听 function addevent(eve,callback){ if (window.attachevent){ window.attachevent("on"+eve,callback); }else if(window.addeventlistener) { window.addeventlistener(eve,callback,false); } } //判断pad横屏竖屏,刷新页面 addevent('load', function(){ // orientationchange(); window.onorientationchange = orientationchange; }); function orientationchange() { switch(window.orientation) { case 0: //alert("肖像模式 0,screen-width: " + screen.width + "; screen-height:" + screen.height); window.location.reload(); break; case -90: //alert("左旋 -90,screen-width: " + screen.width + "; screen-height:" + screen.height); window.location.reload(); break; case 90: // alert("右旋 90,screen-width: " + screen.width + "; screen-height:" + screen.height); window.location.reload(); break; case 180: //alert("风景模式 180,screen-width: " + screen.width + "; screen-height:" + screen.height); window.location.reload(); break; } }; //获取ie浏览器版本 function getbrowserversion(){ var hc = $('html').attr('class'); if(hc){ var ieversion = hc && hc.split(' ')[1]; if(ieversion){ $('.browserupgrade>strong').text(ieversion.touppercase()); } } } getbrowserversion(); //鼠标延迟执行事件方法 $.fn.hoverdelay = function(options){ var defaults = { hoverduring: 200, outduring: 200, hoverevent: function(){ $.noop(); }, outevent: function(){ $.noop(); } }; var sets = $.extend(defaults,options || {}); var hovertimer, outtimer, that = this; return $(this).each(function(){ $(this).on('mouseenter',function(){ cleartimeout(outtimer); hovertimer = settimeout(function(){sets.hoverevent.apply(that)}, sets.hoverduring); }); $(this).on('mouseleave',function(){ cleartimeout(hovertimer); outtimer = settimeout(function(){sets.outevent.apply(that)}, sets.outduring); }); }); } $(function(){ $(window).resize(function(){ var wid = $(window).width(); if(wid < 768){ window.location.reload(); } }) })