利用js实现不同域名显示不同备案的方法

现实项目当中我们经常会遇到到多给域名访问一个页面或者一个站点的时候,限制备案的审核比较严格,就需要域名对应页面要放正确的备案号下面我们可以利用js实现。

  <footer>
    <a href="https://beian.miit.gov.cn"  id="miit"  style="color: #000000" target="_blank">湘ICP备19003460号-1</a>
    <a href="https://www.beian.gov.cn/portal/registersystemInfo?recordcode=44011102002930" id="beian" style="color: #000000" target="_blank" >粤公网安备44011102002930号</a>
    <p>
      <script>
        const domain = location.host;
        const config = {
          'czmz.top': {
            miit: '湘ICP备19003460号-1',
            beian: '粤公网安备44011102002930号',
            code: '44011102002930',
          },
          'czidc.vip': {
            miit: '湘ICP备19003460号-2',
            beian: '粤公网安备44011102003081号',
            code: '44011102003081',
          },
          '0735.pro': {
            miit: '湘ICP备19003460号-3',
            beian: '粤公网安备44011102003089号',
            code: '44011102003089',
          },
          'centos.club': {
            miit: '湘ICP备19003460号-4',
            beian: '粤公网安备44011102003201号',
            code: '44011102003201',
          },
        };

        for (const key in config) {
          const pattern = new RegExp(key);
          if (pattern.test(domain)) {
            const item = config[key];
            document.getElementById('miit').innerHTML = item.miit;
            document.getElementById('beian').innerHTML = item.beian;
            document.getElementById('beian').href = 'https://www.beian.gov.cn/portal/registersystemInfo?recordcode=' + item.code;
          }
        }
      </script>
    </p>
  </footer>
© 版权声明
THE END
喜欢就支持一下吧!
点赞1697 分享