I have Load() function in an external file called cookieRedirect.js and I want to load that function before the <body> tag.
I used to load it like this:
<script type="text/javascript" src="cookieRedirect.js"></script>
</head>
<body onload=Load();>
But when I try this, it’s not working:
<script type="text/javascript" src="cookieRedirect.js">
window.onload = Load();
</script>
</head>
<body>
If you want to load that function before page load, just add script code to the
<head>of the page, not in the body.window.onloadoronload=""will execute your code only when the page was loaded, not before.Do it this way: