Clear Cookie Through JavaScript in iPod/iPad Safari

Introduction

 
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:
  1. document.onclick = ClearCookiesOnClick; //this will run this function on every click. 
Create the calling functions like this:
  1. function ClearCookiesOnClick(e) {  
  2.     if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {  
  3.         var target = (e && e.target) || (event && event.srcElement);  
  4.         // Find the ID of the link for which you want to clear the cookies  
  5.         if (target.id == 'IDOflink') {  
  6.             setCookie("CookieName"'', -2);  
  7.         }  
  8.     }  
  9. }  
  10.   
  11. function setCookie(c_name, value, expiredays) {  
  12.     var exdate = new Date();  
  13.   
  14.     var expires = ((expiredays == null) ? "" : "; expires=" + exdate.toGMTString());  
  15.     document.cookie = c_name + "=" + value + expires + "; path=/";  
That's it; you are good to go.