Merging the DOM function (Document.Write) and scripts in other domains

I want to force external third-party scripts (on separate domains) to use my own implementation of document.write when I upload them to my domain.

t

document.write = function(args) {
    // My custom Function
    }

This works fine for scripts in one domain, but scripts in other domains use the default browser. Can I override this?

+3
source share
1 answer

Here you are:

(window.HTMLDocument ? HTMLDocument.prototype : document).write = function(s) {
    this.title = s;
}

In both IE and non-IE, the "this" object is a browser document object.

0
source

Source: https://habr.com/ru/post/1709408/


All Articles