Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

javascript - Error on clickTag script in HTML5 animated ads banner

I'm using this script for a Ads Banner on a client website. This js code is generated from another agency and seems that it doesn't work because it shows an error when the user click on the banner.

This is the error message:

"The requested URL /6255/REVIVE_ADSERVER_CLICK_URL was not found on this server."

And this is the code that have the clickTag:

  <script>
    var clickTag = "{REVIVE_ADSERVER_CLICK_URL}";
  </script>


    
<script type="text/javascript" gwd-events="support">var gwd = gwd || {};
gwd.actions = gwd.actions || {};
gwd.actions.events = gwd.actions.events || {};
gwd.actions.events.getElementById = function (id) {
    var element = document.getElementById(id);
    if (!element) {
        var pageDeck = document.querySelector("gwd-pagedeck");
        if (pageDeck) {
            if (typeof pageDeck.getElementById === "function") {
                element = pageDeck.getElementById(id)
            }
        }
    }
    if (!element) {
        switch (id) {
            case"document.body":
                element = document.body;
                break;
            case"document":
                element = document;
                break;
            case"window":
                element = window;
                break;
            default:
                break
        }
    }
    return element
};
gwd.actions.events.addHandler = function (eventTarget, eventName, eventHandler, useCapture) {
    var targetElement = gwd.actions.events.getElementById(eventTarget);
    if (targetElement) {
        targetElement.addEventListener(eventName, eventHandler, useCapture)
    }
};
gwd.actions.events.removeHandler = function (eventTarget, eventName, eventHandler, useCapture) {
    var targetElement = gwd.actions.events.getElementById(eventTarget);
    if (targetElement) {
        targetElement.removeEventListener(eventName, eventHandler, useCapture)
    }
};
gwd.actions.events.setInlineStyle = function (id, styles) {
    var element = gwd.actions.events.getElementById(id);
    if (!element || !styles) {
        return
    }
    var transitionProperty = element.style.transition !== undefined ? "transition" : "-webkit-transition";
    var prevTransition = element.style[transitionProperty];
    var splitStyles = styles.split(/s*;s*/);
    var nameValue;
    splitStyles.forEach(function (splitStyle) {
        if (splitStyle) {
            var regex = new RegExp("[:](?![/]{2})");
            nameValue = splitStyle.split(regex);
            nameValue[1] = nameValue[1] ? nameValue[1].trim() : null;
            if (!(nameValue[0] && nameValue[1])) {
                return
            }
            element.style.setProperty(nameValue[0], nameValue[1])
        }
    });

    function restoreTransition(event) {
        var el = event.target;
        el.style.transition = prevTransition;
        el.removeEventListener(event.type, restoreTransition, false)
    }

    element.addEventListener("transitionend", restoreTransition, false);
    element.addEventListener("webkitTransitionEnd", restoreTransition, false)
};
gwd.actions.gwdGenericad = gwd.actions.gwdGenericad || {};
gwd.actions.gwdGenericad.exit = function (receiver, url, opt_collapseOnExit, opt_pageId) {
    gwd.actions.events.getElementById(receiver).exit(url, opt_collapseOnExit, opt_pageId)
}</script>
<script type="text/javascript" gwd-events="handlers">window.gwd = window.gwd || {};
gwd.clickTAG = function (event) {
    clickTAGvalue = dhtml.getVar("clickTAG", "REVIVE_ADSERVER_CLICK_URL");
    landingpagetarget = dhtml.getVar("landingPageTarget", "_blank");
    window.open(clickTAGvalue, landingpagetarget)
};
gwd.auto_Gwd_taparea_1Action = function (event) {
    gwd.actions.gwdGenericad.exit("gwd-ad", "REVIVE_ADSERVER_CLICK_URL", true, "page1")
}</script>
<script type="text/javascript" gwd-events="registration">gwd.actions.events.registerEventHandlers = function (event) {
    gwd.actions.events.addHandler("gwd-taparea_1", "action", gwd.auto_Gwd_taparea_1Action, false);
    gwd.actions.events.addHandler("gwd-taparea_1", "action", gwd.clickTAG, false);
    gwd.actions.events.addHandler("gwd-taparea_1", "action", gwd.clickTAG, false)
};
gwd.actions.events.deregisterEventHandlers = function (event) {
    gwd.actions.events.removeHandler("gwd-taparea_1", "action", gwd.auto_Gwd_taparea_1Action, false);
    gwd.actions.events.removeHandler("gwd-taparea_1", "action", gwd.clickTAG, false);
    gwd.actions.events.removeHandler("gwd-taparea_1", "action", gwd.clickTAG, false)
};
document.addEventListener("DOMContentLoaded", gwd.actions.events.registerEventHandlers);
document.addEventListener("unload", gwd.actions.events.deregisterEventHandlers)</script>
<script data-source="gwdtaparea_min.js" data-version="7" data-exports-type="gwd-taparea">(function () {/*

 Copyright The Closure Library Authors.
 SPDX-License-Identifier: Apache-2.0
*/
    'use strict';
    var f, g = "function" == typeof Object.create ? Object.create : function (a) {
        var b = function () {
        };
        b.prototype = a;
        return new b
    }, h;
    if ("function" == typeof Object.setPrototypeOf) h = Object.setPrototypeOf; else {
        var k;
        a:{
            var l = {o: !0}, m = {};
            try {
                m.__proto__ = l;
                k = m.o;
                break a
            } catch (a) {
            }
            k = !1
        }
        h = k ? function (a, b) {
            a.__proto__ = b;
            if (a.__proto__ !== b) throw new TypeError(a + " is not extensible");
            return a
        } : null
    }
    var n = h, q = this || self, r = function (a, b) {
        function c() {
        }

        c.prototype = b.prototype;
        a.I = b.prototype;
        a.prototype = new c;
        a.prototype.constructor = a;
        a.J = function (d, e, I) {
            for (var x = Array(arguments.length - 2), p = 2; p < arguments.length; p++) x[p - 2] = arguments[p];
            return b.prototype[e].apply(d, x)
        }
    };
    var t = function (a, b, c) {
        c = void 0 === c ? null : c;
        var d = document.createEvent("CustomEvent");
        d.initCustomEvent(a, !0, !0, c);
        b.dispatchEvent(d);
        return d
    };

    function u(a) {
        if (Error.captureStackTrace) Error.captureStackTrace(this, u); else {
            var b = Error().stack;
            b && (this.stack = b)
        }
        a && (this.message = String(a))
    }

    r(u, Error);
    u.prototype.name = "CustomError";
    var v = function (a, b) {
        a = a.split("%s");
        for (var c = "", d = a.length - 1, e = 0; e < d; e++) c += a[e] + (e < b.length ? b[e] : "%s");
        u.call(this, c + a[d])
    };
    r(v, u);
    v.prototype.name = "AssertionError";
    var w = function (a, b, c) {
        if (!a) {
            var d = "Assertion failed";
            if (b) {
                d += ": " + b;
                var e = Array.prototype.slice.call(arguments, 2)
            }
            throw new v("" + d, e || []);
        }
        return a
    }, y = function (a, b) {
        throw new v("Failure" + (a ? ": " + a : ""), Array.prototype.slice.call(arguments, 1));
    };
    var A = function (a, b) {
        this.f = b === z ? a : ""
    };
    A.prototype.A = !0;
    A.prototype.v = function () {
        return this.f.toString()
    };
    A.prototype.toString = function () {
        return "SafeUrl{" + this.f + "}"
    };
    var B = /^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i, z = {};
    var C = [], D = function (a) {
        a = C.indexOf(a);
        0 <= a && C.splice(a, 1)
    };
    document.addEventListener("click", function (a) {
        for (var b = 0; b < C.length; b++) if (25 > Math.abs(a.clientX - C[b].s) && 25 > Math.abs(a.clientY - C[b].u) || 25 > Math.abs(a.screenX - C[b].G) && 25 > Math.abs(a.screenY - C[b].H)) C.splice(b, 1), a.stopPropagation(), a.preventDefault()
    }, !0);
    var E = function () {
        var a = HTMLElement.call(this) || this;
        a.l = 0;
        a.m = 0;
        a.c = null;
        a.h = null;
        a.b = null;
        a.g = null;
        a.i = a.B.bind(a);
        a.a = !0;
        return a
    }, F = HTMLElement;
    E.prototype = g(F.prototype);
    E.prototype.constructor = E;
    if (n) n(E, F); else for (var G in F) if ("prototype" != G) if (Object.defineProperties) {
        var H = Object.getOwnPropertyDescriptor(F, G);
        H && Object.defineProperty(E, G, H)
    } else E[G] = F[G];
    E.I = F.prototype;
    f = E.prototype;
    f.connectedCallback = function () {
        this.b || (this.c = this.j.bind(this), this.h = this.F.bind(this), this.b = this.D.bind(this), this.g = this.C.bind(this));
        this.addEventListener("click", this.c, !1);
        this.addEventListener("touchstart", this.h, !1);
        this.addEventListener("action", this.i, !1)
    };
    f.disconnectedCallback = function () {
        this.removeEventListener("click", this.c, !1);
        this.removeEventListener("touchstart", this.h, !1);
        this.removeEventListener("action", this.i, !1)
    };
    f.j = function (a) {
        this.a && t("action", this, a);
        this.a = !0
    };
    f.F = function (a) {
        this.addEventListener("touchmove", this.b, !1);
        this.addEventListener("touchend", this.g, !1);
        a = a.touches[0];
        this.l = a.clientX;
        this.m = a.clientY
    };
    f.C = function (a) {
        this.j(a);
        this.removeEventListener("touchmove", this.b, !1);
        this.removeEventListener("touchend", this.g, !1);
        a = a.changedTouches[0];
        a = {s: a.clientX, u: a.clientY, G: a.screenX, H: a.screenY};
        C.push(a);
        setTimeout(D.bind(null, a), 2500)
    };
    f.D = function (a) {
        a = a.touches[0];
        this.a = this.a && 10 >= Math.abs(this.l - a.clientX) && 10 >= Math.abs(this.m - a.clientY)
    };
    f.B = function (a) {
        var b = this.getAttribute("exit-id"), c = this.getAttribute("product-index"),
            d = this.getAttribute("exit-override-url");
        d && !t("tapareaexit", this, {
            "exit-id": b,
            url: d,
            "product-index": c,
            "action-event": a.detail
        }).detail.handled && (d instanceof A ? a = d : (a = d, a instanceof A || (a = "object" == typeof a && a.A ? a.v() : String(a), w(B.test(a), "%s does not match the safe URL pattern", a) || (a = "about:invalid#zClosurez"), a = new A(a, z))), b = a, a = q.open, b instanceof A && b.constructor === A ? b = b.f : (c = typeof b, y("expected object of type SafeUrl, got '" +
           

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...