function checkinternetexplorer() {
var bversion = navigator.appversion;
var version = bversion.split(";");
if (version.length > 1) {
var trimversion = parseint(version[1].replace(/[ ]/g, "").replace(/msie/g, ""));
var $body = document.getelementsbytagname("body")[0];
var msg = "
您好,你当前使用的ie浏览器版本过低,为了获取更好的浏览体验,建议你使用谷歌(chrome)\火狐(firefox)等标准浏览器,或升级ie10+以上版本!
";
if (trimversion <= 9) {
msg += $body.innerhtml;
$body.innerhtml = msg;
}
}
}
//保证所有响应式图片列表同一尺寸,避免上传图片尺寸不一致排版混乱
$(function () {
var $imagesamesize = $(".imgae-same-size");
$imagesamesize.each(function () {
var $this = $(this);
var $images = $this.find("img");
if ($images.length == 0) {
return true;
}
var $firstimg = $images.eq(0);
//$(window).on("onload",function(){}) //弃用,效率太低,要等所有页面图片加载完毕才执行
//$images.eq(0).attr("onload", function (){$images.imagesamesize()}); //弃用火狐浏览器下获取不到响应式图片的实际高度
var img = new image();
img.src = $firstimg.attr("src");
img.onload = function () {
$images.imagesamesize();
};
});
});
//自动适应尺寸,如果容器列表项内有图片需要自动适应宽度和高度,所有容器中的图片文件尺寸默认用同级第一个容器尺寸。
;(function ($, window, undefined) {
$.fn.imagesamesize = function (index) {
var $objs = this;
if (index == undefined) {
index = 0;
}
var $templateimage = $objs.eq(index);
var setsize = function () {
var height = $templateimage.css("height").replace(/\s+|px/gi, "");
var width = $templateimage.css("width").replace(/\s+|px/gi, "");
$objs.each(function (idx) {
$(this).css({ "width": width + "px", "height": height + "px" });
});
};
setsize();
var bindresize = $templateimage.attr("data-bindresize");
if (bindresize == undefined) {
$(window).resize(function () {
$templateimage.css({ "width": "auto","height": "auto" });
setsize();
});
$templateimage.attr("data-bindresize", 1);
}
};
})(jquery, window);
//注册响应式菜单
; (function ($, window, undefined) {
$.fn.initnav = function (currentcolumnid,topcolumnid) {
var $navliitem = this;
if (currentcolumnid == undefined) {
currentcolumnid = "0";
}
if (topcolumnid == undefined) {
topcolumnid = "0";
}
//添加子级菜单指示箭头
$navliitem.each(function () {
var $this = $(this);
if ($this.children("ul").length > 0) {
$this.children("ul").children("li").addclass("animated navslide");
$this.append('');
}
var attrdataid = $this.attr("data-id");
if (attrdataid == topcolumnid.tostring()) {
$this.addclass("current active");
}
else if (attrdataid == currentcolumnid)
{
$this.addclass("current active");
var $thisparentli = $this.parentsuntil("div");
$thisparentli.addclass("current active");//给所有的父级li添加current active样式
}
});
//指示箭头注册点击事件
$navliitem.find(".arrow").on("click", function () {
var $this = $(this);
$this.parent("li").toggleclass("active")
});
};
})(jquery, window);
//js无缝滚动代码
function marquee(i, direction) {
var obj = document.getelementbyid("marquee" + i);
var obj1 = document.getelementbyid("marquee" + i + "_1");
var obj2 = document.getelementbyid("marquee" + i + "_2");
if (direction == "up") {
if (obj2.offsettop - obj.scrolltop <= 0) {
obj.scrolltop -= (obj1.offsetheight + 20);
} else {
var tmp = obj.scrolltop;
obj.scrolltop++;
if (obj.scrolltop == tmp) {
obj.scrolltop = 1;
}
}
} else {
if (obj2.offsetwidth - obj.scrollleft <= 0) {
obj.scrollleft -= obj1.offsetwidth;
} else {
obj.scrollleft++;
}
}
}
function marqueestart(i, direction) {
var obj = document.getelementbyid("marquee" + i);
var obj1 = document.getelementbyid("marquee" + i + "_1");
var obj2 = document.getelementbyid("marquee" + i + "_2");
obj2.innerhtml = obj1.innerhtml;
var marqueevar = window.setinterval("marquee(" + i + ", '" + direction + "')", 20);
obj.onmouseover = function () {
window.clearinterval(marqueevar);
}
obj.onmouseout = function () {
marqueevar = window.setinterval("marquee(" + i + ", '" + direction + "')", 20);
}
}