My script sets a cookie named stop_mobi with JavaScript. I am then trying to delete the cookie when a user clicks a link with an onclick event however when I test this the cookie is not deleted. Any pointers to where I am going wrong would be greatly appreciated. Thanks.
<script type="text/javascript">
    // set stop_mobi cookie for test purposes
    function setCookie(cookieName, cookieValue, nDays) {
        var today = new Date();
        var expire = new Date();
        if (nDays == null || nDays == 0) nDays = 1;
        expire.setTime(today.getTime() + 3600000 * 24 * nDays);
        document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
    }
    setCookie("stop_mobi", "yes", "5");
    function deleteCookie(name) {
        document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
        alert('Cookie deleted');
    }
</script>
<a href="" onclick="deleteCookie('stop_mobi');">Delete cookie</a>
 
    