您好,欢迎来到95分类目录!
当前位置:95分类目录 » 站长资讯 » 35dir专区 » 文章详细 订阅RssFeed

35dir前后端提交网站时粘贴的链接自动去掉https(http)://

来源:本站原创 浏览:84次 时间:2025-03-03
简介:前端添加 进入/themes/default目录找到website.html,在最底部的{#include file="footer.html"#}上面加入以下代码         // DOM加载完成后执行         document.addEventListener('DOMContentLoaded', function() {             const urlI

前端添加

进入/themes/default目录找到website.html,在最底部的{#include file="footer.html"#}上面加入以下代码


<script>
        // DOM加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            const urlInput = document.getElementById('web_url');
            
            // 实时输入处理
            urlInput.addEventListener('input', function(e) {
                this.value = sanitizeURL(this.value);
            });


            // 失焦时最终校验
            urlInput.addEventListener('blur', function(e) {
                this.value = finalCheckURL(this.value);
            });
        });


        // 即时清理函数
        function sanitizeURL(url) {
            return url
                .replace(/^s+/, '')         // 去除首部空格
                .replace(/^(https?|ftp):///i,'')  // 移除协议头
                .replace(/^/+/g, '')        // 移除开头的斜杠
                .replace(/s+/g, '')         // 移除所有空格
                .replace(//+/g, '/');       // 合并多余斜杠
        }


        // 最终校验函数
        function finalCheckURL(url) {
            const cleaned = sanitizeURL(url)
                .replace(//+$/g, '')        // 去除末尾斜杠
                .trim();
            
            // 添加自定义校验逻辑(示例)
            if (!cleaned) {
                console.warn('URL不能为空');
            }
            
            return cleaned;
        }
    </script>


后端添加

进入/themes/system目录找到website.html,在最底部的{#include file="footer.html"#}上面加入以下代码

<script>
        // DOM加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            const urlInput = document.getElementById('web_url');
            
            // 实时输入处理
            urlInput.addEventListener('input', function(e) {
                this.value = sanitizeURL(this.value);
            });


            // 失焦时最终校验
            urlInput.addEventListener('blur', function(e) {
                this.value = finalCheckURL(this.value);
            });
        });


        // 即时清理函数
        function sanitizeURL(url) {
            return url
                .replace(/^s+/, '')         // 去除首部空格
                .replace(/^(https?|ftp):///i,'')  // 移除协议头
                .replace(/^/+/g, '')        // 移除开头的斜杠
                .replace(/s+/g, '')         // 移除所有空格
                .replace(//+/g, '/');       // 合并多余斜杠
        }


        // 最终校验函数
        function finalCheckURL(url) {
            const cleaned = sanitizeURL(url)
                .replace(//+$/g, '')        // 去除末尾斜杠
                .trim();
            
            // 添加自定义校验逻辑(示例)
            if (!cleaned) {
                console.warn('URL不能为空');
            }
            
            return cleaned;
        }
    </script>

© 版权声明

推荐站点

  • 我的电视我的电视

    我的电视是一个在线观看高清影视电影的免费站点

    my0713.com
  • 优站库 - 新型分类目录优站库 - 新型分类目录

    一个集网站推荐、内容推荐于一体的宝藏之地。我们精心搜罗各类常用网站,构建起全面的网站目录。无论是学习提升所需的在线课程平台,还是休闲娱乐的影视音乐网站,亦或是商务办公的效率工具站点,都能在我们的分类大全中快速找到。同时,我们也是一个充满活力的建站交流社区。站长们在此分享经验、探讨技术,共同提升网站建设水平。作为网址导航,我们为你清晰分类,节省寻找优质网站的时间和精力。在这里,你无需再为找不到合适的网站而烦恼,只需轻轻一点,就能开启精彩的网络之旅。

    www.uzkoo.com
  • Bible Verse of the DayBible Verse of the Day

    Get your free Bible Verse of the Day

    verseoftheday.online
  • Retro GamesRetro Games

    Play classic retro games online for free. Enjoy NES, SNES, Genesis/MD, Neo Geo, GBA and arcade emulator games directly in your browser. The best free retro games collection.

    classicgamezone.com
  • TikTok動画保存TikTok動画保存

    ティックトック動画を無料でロゴなし保存。高画質でTikTok動画をダウンロードできるサービスです。簡単操作で動画を保存できます。

    ttsavehub.com