Reputation: 63686
This works:
var d = new Date();
document.cookie = name + "=1;expires=" + d.toGMTString() + ";" + "; path=/";
But this doesn't work:
function deletecookie(name)
{
var d = new Date();
document.cookie = name + "=1;expires=" + d.toGMTString() + ";" + "; path=/";
}
deletecookie(name);
Why it doesn't work after wrapping in a function?
EDIT
Seems this only happens in firebug,is there some reason for it?
Upvotes: 0
Views: 122
Reputation: 19692
Firebug often causes all sorts of bugs. Try its latest version and if the problem persists, see this.
Upvotes: 0
Reputation: 67128
Works fine for me in latest version of Firefox so long as you define name before hand:
<script>
var name="hello"
function deletecookie(name)
{
var d = new Date();
document.cookie = name + "=1;expires=" + d.toGMTString() + ";" + "; path=/";
document.write(name);
}
deletecookie(name);
</script>
Upvotes: 1