G
G
Gloynus Aleos2017-06-06 11:06:21
JavaScript
Gloynus Aleos, 2017-06-06 11:06:21

How to execute a page script in Firefox when opening it in an adjacent tab?

There is an HTML page in the "Head" of which the script is standardly connected: . Its code, as expected, is always executed when the page is loaded. Tested in Chrome, Edge, IE11 and Mozilla. But the latter, and only the latter, had an incomprehensible feature: when you open a page in an adjacent tab (for example, by pressing the wheel), the page opens as if this script was not registered on it. Just nothing happens. When the page is reloaded, of course, everything works as it should. I can assume that the point is that this entire script is wrapped as follows:<script src="../js/ready.js"></script>

(function () {
Содержимое...
})();

It should just be executed as soon as the browser reads to it when loading the HTML page.

Who faced: tell me how to fix the situation?

So far, the problem was solved by reloading the page when receiving focus:
function ContentVerification() {
  if ($('#content > p').text() == 'Попытка загрузить инструкцию...') {
    window.location.reload();
  }
}
$(window).focus(function() {
  if ($('#content > p').text() == 'Попытка загрузить инструкцию...') {
    setTimeout(ContentVerification, 500);
  }
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay, 2017-06-06
@iNickolay

Maybe you just forgot ()?
Those.

(function () {
Содержимое...
})();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question