Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS: body tag onload equivalent?

Tags:

javascript

I need to basically add this to my page:

<body onload="document.getElementById('WeddingBandBuilder').focus()">

However due to my template I cannot change the tag. So is there a way to do the equivalent with a script in the < head > tag or something?

Thanks!

like image 382
JD Isaacks Avatar asked Dec 13 '25 04:12

JD Isaacks


1 Answers

<script>
window.onload = function() {document.getElementById('WeddingBandBuilder').focus()};
</script>
like image 85
SpliFF Avatar answered Dec 14 '25 17:12

SpliFF