In iPod/iPad safari if
you excess your main site made in .net and want to clear the cookies through
JavaScript as user goes to another page, iPod/iPad doesn't support "onbeforeunload"
event so what you do?
Add the following on the
aspx page in script tag:
- document.onclick = ClearCookiesOnClick;
Create
the calling functions like this:
- function ClearCookiesOnClick(e) {
- if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
- var target = (e && e.target) || (event && event.srcElement);
-
- if (target.id == 'IDOflink') {
- setCookie("CookieName", '', -2);
- }
- }
- }
-
- function setCookie(c_name, value, expiredays) {
- var exdate = new Date();
-
- var expires = ((expiredays == null) ? "" : "; expires=" + exdate.toGMTString());
- document.cookie = c_name + "=" + value + expires + "; path=/";
- }
That's it; you are good to go.