How to intercept HTTP site request using javascript?

I need to connect all the URLs of links, images, css and js on my site and perform some operation when an event occurs with this.

Does anyone know how to handle all these events?

+3
source share
3 answers

JQuery

$("link, script, style, a, img").each(function(){
    $(this).load(function(){
        // do stuff when each of these elements is loaded
    });
});

Not quite sure if this is what you want, since your question is not very clear, but you can associate something with a load event for each of these types of elements.

+2
source

Event handlers? <body onload="somefunction"> <img src="blah.jpg" onLoad="somejavascriptfunction()" onclick="someotherfunction">etc.

Can be done with most items.

0
source

, jQuery. - :

$('a').click(somefunction);
0

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


All Articles