I’ve got an image background which content I want to be always visible, no matter what is the user’s resolution. Therefore, I want to be able to determine what is the resolution and set appropriate background image file before page loads, on the very beginning. Is it possible somehow?
Share
The earliest point at which you can run a Javascript function with access to the DOM (without waiting for page load) is by placing a
<script>tag right after the opening<body>tag.Scripts inside the
<head>will run before this occurs, but there won’t be access to the elements on the page.Try this code
See this example with some Gangsta Lipsum text.