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>
    <html>
    <head>
        <meta charset='utf-8'>
        <title>Window Size</title>
        <SCRIPT language='JavaScript'>
        <!--
        function new_win()
        {
            window.open('http://schw.im/?action=socialcontrol','socialcontrol','width=".$w.",height=250,screenX=50,left=50,screenY=50,top=50,status=no,menubar=no');
        }
        //-->
        </SCRIPT>
    </head>
    <body>
    Window size is:<br><br>
    Width: ".$w."<br>
    Height: ".$h."
    <form>
    <input type=button value='Open Windows' onclick='new_win()'>
    </form>
    </body>
    </html>

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>