Javascript code doesn't execute : <p>My javascript code just won't work. If I simply put <code>&lt;script&gt;alert("alert");&lt;/script&gt;</code> in my code, it works as normal, but the big chunk of script in the following code is seemingly ignored. The code is meant to submit a hidden form when the use clicks a link. Is this a simple missing curly brace, or something more difficult?  </p>

<p>The Code follows:  </p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script&gt;
function $_GET(q,s) {
    s = (s) ? s : window.location.search;
    var re = new RegExp('&amp;amp;'+q+'=([^&amp;amp;]*)','i');
    return (s=s.replace(/^\?/,'&amp;amp;').match(re)) ?s=s[1] :s='';
}

function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}

function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i&lt;ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
    }
    return "";
}

Date.prototype.addDays = function(days)
{
    var dat = new Date(this.valueOf());
    dat.setDate(dat.getDate() + days);
    return dat;
}

function stripGet(url) {
  return url.split("?")[0];
}

function load() {

alert('load');
document.getElementByName('link').onclick=onsubmit;

if($_GET('l') === "penguin"){
setCookie('expiry', new Date.addDays(30), 400);
setCookie('expired', 'FALSE', 30);
window.location = stripGet(window.location);
}
}

function onsubmit(){

alert('on submit');

if (new Date() &gt; new Date(getCookie('expiry') || getCookie('expired') == 'TRUE') {
alert("expired");
setCookie('expired', 'TRUE', 1000);
window.location ='???';
return false;
}
else {
alert("valid");
document.getElementByName('username').value = atob('???');
document.getElementByName('username').value = atob('???');
document.forms['form'].submit();
return true;
}

&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="load()" bgcolor="green" top="45%" align="center" link="orange" active="blue" visited="orange"&gt;

&lt;form name="form" action="submit.php" method="POST"&gt;
&lt;input name="__formname__" type="hidden" value="loginform"&gt;
&lt;input name="username" type="hidden"&gt;
&lt;input name="username" type="hidden"&gt;
&lt;/form&gt;

&lt;a name="link" href="javascript:onsubmit();" onclick="alert("click"); onsubmit(); return true;"&gt;
&lt;h1 style="font-size: 84pt; padding-top: 1.5cm"&gt;
Submit form
&lt;/h1&gt;
&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
