1

Sometimes this script does not work, I am using it in a php file

    <script type="text/javascript">
        window.onload = function () {
          var input = document.body.getElementById("thisActive");
          input.focus();
          input.select();
        }
    </script>

here is work http://cartoon.22web.org/watch/s-watch/index.php

After the page load is complete, the script specifies the link to the page ===========================

But here using multiple pages http://wassim-al-ahmad.22web.org

not selected page selected

Wassim Al Ahmad
  • 1,102
  • 2
  • 7
  • 23
  • 2
    1. Contrary to popular belief `window.onload` can fire before the DOM has loaded. You should use [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event) which fires when the DOM has loaded *and* has been parsed. 2. Show us your respective HTML. – Script47 Sep 04 '19 at 08:51

4 Answers4

2

Just convert window to document like this:

document.onload = function () {
    var input = document.body.getElementById("thisActive");
    input.focus();
    input.select();
}

JQuery version

$(document).ready(function () {
    ...
});
Saeid Amini
  • 1,313
  • 5
  • 16
  • 26
2

You have seen the code and the reason for the priority You are using JavaScript at the beginning of the code and then create a menu to select an item from a database using PHP multiple pages You must use the script at the end of the code

mohanad al
  • 21
  • 5
2

Use PHP to view the data from the database starting with the page order currently displayed. You do not need to use the script you have ever typed in your HTML code.

mario
  • 21
  • 3
1

i had the same problems just you have to change your host if you used free host you must change the host to

samo
  • 36
  • 3