I am trying to run an external javascript function when the page loads and the function takes a variable that I can only pass through the page which where the javascript function is called from.
HTML Page
<head>
<script src="path/to/file.js" type="text/javscript>
window.onload = function() {
doFunction(variable);
}
</script>
</head>
Javascript file
function doFunction(variable){
//do the stuff here
}
<script>element can either have asrcor inline code, not both in one. Move the inline code to a 2nd<script>element. – Inline Script with SRC Attribute?<script>element after the current</script>. Move the inline JavaScript into it.