$(function() { //字体大中小 $(".switchsize span").click(function() { //获取para的字体大小 var thisele = $(".m-ct-artcle p,.m-ct-artcle,.m-ct-artcle font,.m-ct-artcle span,.m-ct-artcle div").css("font-size"); //parsefloat的第二个参数表示转化的进制,10就表示转为10进制 var textfontsize = parsefloat(thisele, 10); //javascript自带方法 var unit = thisele.slice(-2); //获取单位 var cname = $(this).attr("class"); if(cname == "bigger") { if(textfontsize <= 22) { textfontsize += 2; } } else if(cname == "smaller") { textfontsize -= 2; } //设置para的字体大小 $(".m-ct-artcle p,.m-ct-artcle,.m-ct-artcle font,.m-ct-artcle span,.m-ct-artcle div").css("font-size", textfontsize + unit); }); $(".switchsize .medium").click(function() { $(".m-ct-artcle p,.m-ct-artcle,.m-ct-artcle font,.m-ct-artcle span,.m-ct-artcle div").css("font-size", "16px"); }) //打印 var printareacount = 0; $.fn.printarea = function() { var ele = $(this); var idprefix = "printarea_"; removeprintarea(idprefix + printareacount); printareacount++; var iframeid = idprefix + printareacount; var iframestyle = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;'; iframe = document.createelement('iframe'); $(iframe).attr({ style: iframestyle, id: iframeid }); document.body.appendchild(iframe); var doc = iframe.contentwindow.document; $(document).find("link").filter(function() { return $(this).attr("rel").tolowercase() == "stylesheet"; }).each( function() { doc.write(''); }); doc.write('
' + $(ele).html() + '
'); doc.close(); var framewindow = iframe.contentwindow; framewindow.close(); framewindow.focus(); framewindow.print(); } var removeprintarea = function(id) { $("iframe#" + id).remove(); }; //打印调用 var list01li = $('.list01 li'); var li_len = list01li.length; if(li_len == 0) $('.xg-list').hide(); $('.contentcon img').parent('span').css('text-indent', 0) //鼠标滑过变透明 function hoverfade(butn) { $(butn).hover( function() { $(this).fadeto(200, .8) }, function() { $(this).fadeto(200, 1) } ) } hoverfade('.butn,.newpicture dl'); //回到顶部 $(".back_top").hide(); //首先将.back_top隐藏 $(window).scroll(function() { if($(window).scrolltop() > 0) { $(".back_top").fadein(400); } else { $(".back_top").fadeout(400); } }); //当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失 $(".back_top a").click(function() { $('body,html').animate({ scrolltop: 0 }, 200); return false; }); //当点击跳转链接后,回到页面顶部位置 //设置左侧最小高度 var leftheight = $('.leftpart').height(); var rightheight = $('.rightpart').height(); if(leftheight < rightheight) { $('.leftpart').height(rightheight); } })