function Sto(id){ $("html,body").animate({scrollTop: $('#'+id).offset().top-150}, 1000); return false;// 返回false可以避免在原链接后加上# } $(document).ready(function () { $('.gn-list >li').hover( function () { $(this).addClass("active"); var current_li = $(this); if (!$(current_li).children('.dropdown').is(':visible') && $('.dropdown').find('a').length > 0) { $(current_li).find('.dropdown').slideDown(200); } } , function () { $(this).find('.dropdown').slideUp(100); $(this).removeClass("active"); }); if (li_id) { $("#" + li_id + " >a").addClass("active1"); }; //禁止右键 $('body').bind('contextmenu', function() { return false; }); //禁止选中 if (document.all) { document.onselectstart = function () { return false; }; //for ie } else { document.onmousedown = function () { return false; }; document.onmouseup = function () { return true; }; } document.onselectstart = new Function('event.returnValue=false;'); }) function popupDiv(div_id) { //根据自己需求注意宽度和高度的调整 var iWidth = document.documentElement.clientWidth; var iHeight = document.documentElement.clientHeight; //遮罩层 var bgObj = document.createElement("div"); bgObj.setAttribute("id", "bgObj"); //设置ID bgObj.setAttribute("onclick", "hideDiv('" + div_id + "')"); bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:" + Math.max(document.body.scrollWidth, iWidth) + "px;height:" + Math.max(document.body.scrollHeight, iHeight) + "px;filter:Alpha(Opacity=30);opacity:0.1;background-color:#000000;z-index:20000;"; document.body.appendChild(bgObj); var div_obj = $("#" + div_id); var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; var popupHeight = div_obj.height(); var popupWidth = div_obj.width(); //添加并显示遮罩层 //$("
").addClass("overlap") //.width(windowWidth * 0.99) //.height(windowHeight * 0.99) //.click(function() {hideDiv(div_id); }) //.appendTo("body") //.fadeIn(200); div_obj.fadeIn(500); div_obj.css({ "position": "fixed", "z-index": "30000", "left": windowWidth / 2 - popupWidth / 2, "top": windowHeight / 2 - popupHeight / 2 }).animate({ opacity: "show" }, "slow"); } function hideDiv(div_id) { $("#bgObj").remove(); //$("#mask").remove(); $("#" + div_id).fadeOut(500); }