限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

jquery高仿谷歌搜索首页添加网站常用链接插件

所属分类: 网页特效-导航菜单    2025-01-18 03:11:05

jquery高仿谷歌搜索首页添加网站常用链接插件 ie兼容9
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery高仿谷歌搜索首页添加网站常用链接插件(共3个文件)

    • index.html

使用方法

const $siteList = $('.siteList');
const $lastLi = $('li.last');
const x = localStorage.getItem('x');
const xObject = JSON.parse(x);

const hashMap = xObject || [
    {
        logo: 'K',
        url: 'https://www.kuli8.com'
    },
    {
        logo: 'B',
        url: 'https://www.baidu.com'
    }
];

const simplifyUrl = (url) => {
    const newUrl = url.replace('https://', '')
        .replace('http://', '')
        .replace('www.', '')
        .replace(/\/.*/, '');
    return newUrl;
};

const render = () => {
    $siteList.find('li:not(.last)').remove();
    hashMap.forEach((node, index) => {
        const $li = $(`
            <li>
                <div class="site">
                    <div class="logo">${node.logo}</div>
                    <div class="link">${simplifyUrl(node.url)}</div>
                    <div class="close">
                        <i class="fas fa-times"></i>
                    </div>
                </div>
            </li>
        `).insertBefore($lastLi);

        (function () {
            let sUserAgent = navigator.userAgent;
            if (sUserAgent.indexOf('Android') > -1 || sUserAgent.indexOf('iPhone') > -1 || sUserAgent.indexOf('iPad') > -1 || sUserAgent.indexOf('iPod') > -1 || sUserAgent.indexOf('Symbian') > -1) {
                console.log("Mobile");
                let timeOut = null;
                $li.on('click', () => {
                    window.clearTimeout(timeOut);
                    timeOut = setTimeout(() => {
                        window.open(node.url);
                    }, 200);
                    // window.open(node.url);
                });

                const $close = $(".close");
                $li.on('dblclick', function () {
                    window.clearTimeout(timeOut);
                    $close.style.display = 'block';
                });
            } else {
                console.log("Desktop");
                $li.on('click', () => {
                    window.open(node.url);
                });
            }
        })();


        $li.on('click', '.close', (e) => {
            console.log('Remove Event');
            e.stopPropagation();
            hashMap.splice(index, 1);
            window.localStorage.setItem('x', JSON.stringify(hashMap));
            console.log(hashMap);
            render();
        });
    });
};

render();

$('.addButton').on('click', () => {
    let url = window.prompt("URL:");
    if (url.indexOf('www') === 0) {
        url = 'https://' + url;
    }
    else if (url.indexOf('http') === 0 && url.indexOf('https') <= -1) {
        if (url.indexOf('www') > -1) {
            url = 'https://' + url.substring(7);
        } else {
            url = 'https://www.' + url.substring(7);
        }
    }
    else if (url.indexOf('https') === 0) {
        if (url.indexOf('www') > -1) {
            url = url;
        } else {
            url = 'https://www.' + url.substring(8);
        }
    } else {
        url = 'https://www.' + url;
    }
    hashMap.push({
        logo: simplifyUrl(url)[0].toUpperCase(),
        url: url
    });
    window.localStorage.setItem('x', JSON.stringify(hashMap));
    console.log('Add Event');
    console.log(hashMap);
    render();
});

$(document).on("keypress", e => {
    const {key} = e;
    console.log(key);
    for (let i = 0; i < hashMap.length; i++) {
        if (hashMap[i].logo.toLowerCase() === key) {
            window.open(hashMap[i].url);
        }
    }
});
$('input').on('keypress', (e) => {
    e.stopPropagation();
});

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 导航菜单

jquery hover仿淘宝商城鼠标滑过展开更多导航菜单分类列表

鼠标滑过显示更多的导航菜单,悬浮覆盖其它区域,比较实用的功能!
  导航菜单
 1281  0

jquery响应式下拉二级导航菜单特效代码

一款响应式垂直二级导航菜单代码,电脑端和手机端显示不一样的样式布局,大家可以试试哈。
  导航菜单
 9401  0

jquery响应式全屏导航菜单特效代码

一款响应式全屏导航插件,可尝试改变浏览器显示大小,导航菜单有不一样的变化。
  导航菜单
 584  0

纯CSS实现的响应式底部导航菜单特效

一款页面底部导航菜单代码,导航菜单模块固定在页面底部,每个导航菜单由图标组成,鼠标悬停显示边框阴影效果。
  导航菜单
 2105  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论