I have a function that is executed when a link is clicked that contains certain content, but the situation is that after the click, the page is refreshed. I want to make it so that after refreshing the page my function would still be executed, tell me how to do it? For example, after clicking on the button, the function waits until the page is reloaded and after that it has already been completed. My code:
function refreshContent() {
...function here
}
var textProp = 'textContent' in document ? 'textContent' : 'innerText';
[].slice.call(document.querySelectorAll('a'), 0).forEach(function (aEl) {
if (aEl[textProp].indexOf('English') > -1) {
aEl.addEventListener("click", refreshContent)
}
})
I need that when I click on the link:
aEl.addEventListener("click", refreshContent))
, the script waits until the page is updated and after that the function refreshContent is executed