I am starting to believe that some virus infected my PC.
Recently I have a post about problem during loading an external file, but I have also the same problem in 'in-document' scripts.
The script won't be loaded!!! However, it 'load' script, but have no access to any element in the document, unless I specified a scripts elements right before body closing tag.
However, that's happened only with a files made by myself. If i try some exercise from the book example (where script tag or script importing occurs right in the head element) everything works just fine. Do you get it???
I would introduce the test example and explanation of its behavior, tested in IE, Opera, Firefox, Safari.
script inside head element
Won't work in neither browser, no events occurs on click, and IE report the error div is null or not an object Next, script is put right after opening body tag :
Won't work in neither browser, no events occurs on click, and IE report the error div is null or not an object.
Next, put scripts right before closing body element.
Works fine in each browser!
I am really on the edge of my nerves, so please, does anyone has an explanation for my problem???
Hi Bear. My intention was not certainly to make some reputation of mine.Recently I have a strange behavior of my PC, due to virus, so I just have been suspicious (at least 1 hour re-installation of my system is the most worse scenario).
About my question, I figure out that objects were not read, the DOM tree isn't created when my js are invoked, but I was confused little. I resolved any doubt's by using JQuery, something like this :
Thanks Bear. As much as conclude, use of JQuery is greater as it have a capability to act on the DOM elements, right after DOM configuration ( I do not need to wait entire page content to be loaded.images, etc.), where, when using onload handler, entire page must be rendered (including entire content), before I can act on the DOM. Right?