/    Sign up×
Community /Pin to ProfileBookmark

Delete cookies button!

Hi there,

this is my site:

[URL=”www.shape-studio.co.uk/index.html”]www.shape-studio.co.uk/index.html
[/URL]

The drag and drop menus use cookies called “menubox” and “textbox” to record the coordinates of the divs so they stay in place from page to page. This is the drag and drop script:

[URL=”www.shape-studio.co.uk/text/dnd.js”]www.shape-studio.co.uk/text/dnd.js
[/URL]

I would like a simple button (link) that the user can click that will delete these cookies and reload the current page, thus returning the menus back to their default position.

This has been driving me crazy! Any help much appreciated!

Thanks
Dominic

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 23.2008 — var d = new Date();
document.cookie = "menubox='';expires=" + d.toGMTString() + ";;";
document.cookie = "textbox='';expires=" + d.toGMTString() + ";;";
Copy linkTweet thisAlerts:
@dominicbellauthorSep 23.2008 — Hi Fang,

Great, thanks for that.

Do you know how I'd incorporate that into a link which also refreshes the current page?

Sorry, complete javascript newbie!

Thanks

Dom
Copy linkTweet thisAlerts:
@FangSep 23.2008 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>refresh</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
function refresh() {
var d = new Date();
document.cookie = "menubox='';expires=" + d.toGMTString() + ";;";
document.cookie = "textbox='';expires=" + d.toGMTString() + ";;";
window.location.reload(true); // update from server
return false;
}
</script>

</head>
<body>
<a href="#" onclick=" return refresh();">refresh</a>
</body>
</html>
×

Success!

Help @dominicbell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...