PageSourceSearch

https://yunfu.gov.cn/xb/js/layer.js

js yunfu.gov.cn collected 2026-10-02 16:27:18 UTC 2,861 bytes, 91 lines download raw bytes

1 /****************************离开链接********************************/
2// 统一弹窗函数
3function showRedirectWarning(url) {
4    const outUrlEl = document.getElementById('outUrl');
5    if (outUrlEl) outUrlEl.innerText = url;
6    const hashEl = document.getElementById('hash');
7    if (hashEl) hashEl.click();
8    
9    $(".alert-mengban").fadeIn(200);
10    $(".alert-warning").delay(200).show().animate({top: "200px"}, 300);
11}
12
13// 初始化弹窗关闭事件
14$(function() {
15    $("#closets, .fangqi, .alert-mengban").off("click").on("click", function() {
16        $(".alert-warning").animate({top: "-400px"}, 200).hide(300);
17        $(".alert-mengban").delay(300).fadeOut(300);
18    });
19
20    $(".continue").off("click").on("click", function() {
21        $(".alert-warning").hide(200);
22        $(".alert-mengban").delay(200).fadeOut(200);
23    });
24});
25
26// 检查是否需要弹窗的函数(最终优化版)
27function shouldTriggerPopup(url) {
28    // 无URL或无效URL
29    if (!url || typeof url !== 'string') return false;
30    
31    const lowerUrl = url.toLowerCase();
32    
33    // 排除以下情况:
34    // 1. 空链接
35    // 2. JavaScript伪协议
36    // 3. 纯锚点链接
37    // 4. 当前页面链接
38    if (lowerUrl === "" || 
39        lowerUrl.startsWith('javascript:') || 
40        lowerUrl === '#' || 
41        lowerUrl.startsWith('#') ||
42        lowerUrl === window.location.href.toLowerCase()) {
43        return false;
44    }
45    
46    try {
47        // 使用URL对象处理各种格式的URL
48        const urlObj = new URL(lowerUrl, window.location.origin);
49        
50        // 白名单检查:特定路径和域名
51        const hostPath = urlObj.hostname + urlObj.pathname;
52        
53        const isSpecificPath = (
54            hostPath === 'search.gd.gov.cn/search/all/766001'
55        );
56        
57        const isYunfuDomain = (
58            urlObj.hostname.endsWith('.yunfu.gov.cn') || 
59            urlObj.hostname === 'yunfu.gov.cn'
60        );
61        
62        // 只在这些白名单情况下不弹窗
63        return !(isSpecificPath || isYunfuDomain);
64        
65    } catch (e) {
66        // 对于无法解析为有效URL的链接按不需要弹窗处理
67        return false;
68    }
69}
70
71// 链接点击事件处理
72$("a").on("click", function(e) {
73    const url = this.href || $(this).attr('href') || '';
74    
75    if (shouldTriggerPopup(url)) {
76        showRedirectWarning(url);
77        e.preventDefault();
78        return false;
79    }
80});
81
82// 下拉框变更事件处理
83$("select").on("change", function() {
84    const url = $(this).find("option:selected").val() || '';
85    
86    if (shouldTriggerPopup(url)) {
87        showRedirectWarning(url);
88        return false;
89    }
90});
91/****************************离开链接********************************/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.