function loadStyleText(cssText) { var style = document.createElement('style'); style.rel = 'stylesheet'; style.type = 'text/css'; try { style.appendChild(document.createTextNode(cssText)); } catch (e) { style.styleSheet.cssText = cssText; } var head=document.getElementsByTagName("head")[0]; head.appendChild(style); } jQuery.fn.floatadv = function(loaded) { var obj = this; body_height = parseInt($(window).height()); block_height = parseInt(obj.height()); top_position = parseInt((body_height/2) - (block_height/2) + $(window).scrollTop()); if (body_height<block_height) { top_position = 0 + $(window).scrollTop(); }; if(!loaded) { obj.css({'position': 'absolute'}); obj.css({ 'top': top_position }); $(window).bind('resize', function() { obj.floatadv(!loaded); }); $(window).bind('scroll', function() { obj.floatadv(!loaded); }); } else { obj.stop(); obj.css({'position': 'absolute'}); obj.animate({ 'top': top_position }, 400, 'linear'); } } $(function (){ $("body").after('<div id="duiLianL"><div id="duiLian_con"><table id="__01" width="136" height="412" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="ad_images/ad_01.png" width="136" height="68" alt=""></td></tr><tr><td><a href="/Login"><img src="ad_images/ad_02.gif" width="136" height="69" alt=""></a></td></tr><tr><td><a href="/Login"><img src="ad_images/ad_03.gif" width="136" height="63" alt=""></a></td></tr><tr><td><a href="/Mobile"><img src="ad_images/ad_04.gif" width="136" height="66" alt="mobile"></a></td></tr><tr><td><a href="/Mobile"><img src="ad_images/ad_05.png" width="136" height="118" alt=""></a></td></tr><tr><td><span id="duiLianL_Close"><img src="ad_images/ad_06.png" width="136" height="28" alt=""></span></td></tr></table></div></div><div id="duiLianR"><div id="duiLian_con"><table id="__01" width="136" height="412" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="ad_images/kf-2_01.png" width="136" height="68" alt=""></td></tr><tr><td><a href="http://messenger3.providesupport.com/messenger/043hc3vsx2ceg028sispfa4v8w.html" target="_blank"><img src="ad_images/kf-2_02.png" width="136" height="69" alt="在线客服"></a></td></tr><tr><td><a href="/Login"><img src="ad_images/kf-2_03.gif" width="136" height="45" alt=""></a></td></tr><tr><td><a href="http://wpa.qq.com/msgrd?v=3&uin=87844288&site=qq&menu=yes" target="_blank"><img src="ad_images/kf-2_04.png" width="136" height="61" alt="QQ客服"></a></td></tr><tr><td><img src="ad_images/kf-2_05.png" width="136" height="141" alt=""></td></tr><tr><td><span id="duiLianR_Close"><img src="ad_images/kf-2_06.png" width="136" height="28" alt=""></span></td></tr></table></div></div>'); var screenH=screen.height; var duiLianTop=0; if (screenH>=768){ duiLianTop=130; //顶部距离 } loadStyleText("#duiLianL{ position:fixed; left:5px; top:"+duiLianTop+"px; border:0px solid gray; z-index:999} #duiLianR{ position:fixed; right:5px; top:"+duiLianTop+"px; border:0px solid gray;z-index:999} #duiLian_con{ 100%; height:100%;line-height:100%;overflow:hidden;text-align:center;background-color:#FFFFFF; border:0px solid red;} #duiLianL_Close,#duiLianR_Close {100%; overflow:hidden;text-align:center;cursor:pointer; float:left; border:0px solid red;}"); $("#duiLianL,#duiLianR").floatadv(); $('#duiLianL_Close').click(function(){ $('#duiLianL').hide(); }); $('#duiLianR_Close').click(function(){ $('#duiLianR').hide(); }); });