Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Episerver Find.js replacing the entire window.onload event

Vote:
 

Hi,

I don't know if this is the right place to report this for Episerver.Find.

Somewhere earlier in my HTML page, I have a script that attaches a handler to the window.load event

window.onload = function() {}

However this is not being triggered because somewhere lower on the page, there is a find.js (https://dl.episerver.net/12.4.3/epi-util/find.js) that completely replaces the window.load instead of attaching another event handler to the window.load and it is this particular snippet:

 this.bindWindowEvents = function() {
        var t = this;
        window.history && (window.onbeforeunload = function() {
            var e = document.location.href;
            e.indexOf("q=") > 0 && -1 == e.indexOf(t._dontTrackQueryParam + "=") && window.history.replaceState(window.history.state, window.document.title, e + (e.indexOf("?") > 0 ? "&" : "?") + t._dontTrackQueryParam + "=true")
        }
        ),
        window.onload = function() {
            var e = t._toArray(document.getElementsByTagName("A"))
              , r = document.createElement("A");
            r.href = document.location.href;
            for (var n = 0; e.length > n; n++) {
                var a = function() {
                    var a = e[n].href
                      , i = t._getTrackQueryParamsFromUrl(a);
                    if (i.trackQueryParams.length > 0) {
                        var o = document.createElement("A");
                        o.href = a,
                        ("/" != t._applicationUrl && r.hostname + t._applicationUrl != o.hostname + "/" + o.pathname.split("/")[1] + "/" || "/" === t._applicationUrl && r.hostname != o.hostname) && (e[n].href = t._serviceApiBaseUrl + "_click?" + t._trackParam + i.trackQueryParams.join("&" + t._trackParam) + "&" + t._trackParam + "redirect=" + encodeURIComponent(t._getUriWithoutTrackParams(a, i)))
                    }
                };
                a()
            }
        }
    }

Can we request for the window.onload to be something like this?

window.addEventListener("load", epiFindFunctionHere, false);

So it doesn't erase any event handlers already attached?

Thanks

#178624
May 16, 2017 4:20
Vote:
 

Noticed the same. cool

#194990
Jul 10, 2018 20:30
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.