Do some JavaScript in Controller

hi guys, I want to inegrate following JS-Code in any Controller of Yii2. It must be inside Controller.

Any ideas, if this is possible, and if, how?

Background of this question is this thread





<script type="text/javascript">

function fensterOeffnen() { 

  window.open('https://forum.selfhtml.org/');

}

</script>

<button type="button" onclick=fensterOeffnen()>Click Me!</button>



It is better to place the script needed at the bottom of the view page where it’s used.