Changing js action from form button to text link and on page load

Hi there everyone!

I’ve got some script that opens a sized window:

<!doctype html>
        <meta charset='utf-8'>
        <title>Window Size</title>
        <SCRIPT language='JavaScript'>
        function new_win()
    Window size is:<br><br>
    Width: ".$w."<br>
    Height: ".$h."
    <input type=button value='Open Windows' onclick='new_win()'>

but instead of the form button opening the window, I need to implement it in two different ways. On one page, I’m going to need to tie the new_win function to a text link and on another page, I need the new_win function to occur when the page loads.

Could someone help me with how to make those two things happen?

Thanks for your time!

Text link: <a href=“javascript:void(0);” onclick=“new_win();”>Random text</a>

Upon page load (risk of upsetting user): <body onload=“new_win();”> content </body>