$(function () { // 拿到域名 www.bonabio.com // var url = window.location.host; var url = 'bonabio.'; // console.log(url); // let urllen = url.split('.').length - 1; // if (urllen >= 2) { // var regex = /\.(.*)/; // var match = url.match(regex); // if (match) { // var url = match[1]; // } // } $('a').each(function () { let hrefurl = $(this).attr('href'); // 判断有没有域名 if (hrefurl?.includes(url) && !hrefurl?.includes('en.')) { // 有就把链接的域名去掉 let newurl = hrefurl.replace(/(^https?:\/\/[^\/]+)/, ''); // console.log(hrefurl); // console.log(newurl); $(this).attr('href', newurl); } }); $(".menu-a").hover(function () { $(this).find(".submenu").show(); }, function () { $(this).find(".submenu").slideup(100); }) $(".submenu1").hover(function () { $(this).find(".submenu2").fadein(100); }, function () { $(this).find(".submenu2").hide(); }) // 关于我们 点击 $(".submenu a[data-s]").click(function () { let url = window.origin + '/index.php?id=abouts'; url = url + '&s=' + $(this).data("s"); console.log(url) // window.location = url; window.open(url); return false; }) function scrollfun() { // 页面滚动监听 let scrolltop = $(window).scrolltop(); // 判断头部 if (scrolltop > 0) { $("header").addclass("headertop") } else { $("header").removeclass("headertop") } if (scrolltop > 150) { // 判断右侧菜单 $(".right").fadein(); } else { $(".right").fadeout(); } } scrollfun() // 页面滚动监听 初始化 $(window).scroll(function () { // 页面滚动监听 scrollfun() }) // 动画初始化 if (window.scrollreveal) { window.scrollreveal = new scrollreveal({ reset: true }); } //页面滚动至顶部 $('.gotop').click(function () { $('html,body').animate({ scrolltop: '0px' }, 200); }); });