Назад в раздел Cookie
 

Убить куки...        

 

Cookie Name:
Path:
Domain:
  This function deletes the specified cookie from the current document's cookie file. If a PATH or DOMAIN was specified when the cookie was set, they must be specified in order to delete the cooke as well. 


Содержимое этой таблицы поместите между <HEAD> и </HEAD>

 

<SCRIPT LANGUAGE="javascript">

<!--

//behavior "Cookie Library"

// Copyright 1997 Webmonkey. All rights reserved.



//*************** LOCALIZEABLE GLOBALS VARS *****************


var MSG_AnchorNotFound = 'The anchor "%s" that was set to %s could not be found.';

var MSG_NoCookieValueSet = "Please provide a Cookie Name.";

var MSG_WrongNumberOfArgs = "The function call for this event has been corrupted. Please hit Cancel, delete the Action, and try again."


var TYPE_Separator = "in";

var TYPE_Form = "form";

var TYPE_Layer = "layer";

var TYPE_Image = "image";

var TYPE_Anchor = "anchor";


//Params for the WindowDimensions fn which improves performance by hardcoding window size.

var WINDOWSIZE_Autosize = false; //if you change the UI, set to true or update these numbers.

var WINDOWSIZE_Mac = "452,216"; //ignored if WINDOWSIZE_Autosize is true

var WINDOWSIZE_Win = "438,238"; //ignored if WINDOWSIZE_Autosize is true


//Note: HTML labels (at the end of this file) must be changed by hand



//*************** GLOBALS VARS *****************


var REF_UNNAMED = "unnamed <"; //this is what getObjectRefs() returns for unnamed objects

var REF_CANNOT = "cannot reference <";



//******************* BEHAVIOR FUNCTIONS **********************


function WM_killCookie(name, path, domain) {

var firstChar, lastChar, theValue;

// get the entire cookie string (this may have other name=value pairs in it

var theBigCookie = document.cookie;

// grab just this cookie from theBigCookie string

// find the start of 'name'

firstChar = theBigCookie.indexOf(name);

// if you found it

if(firstChar != -1) {

// skip 'name' and '='

firstChar += name.length + 1;

// find the end of the value string (i.e. the next ';')

lastChar = theBigCookie.indexOf(';', firstChar);

if(lastChar == -1) lastChar = theBigCookie.length;

// set theValue

theValue = theBigCookie.substring(firstChar, lastChar);

} else {

// there is no such cookie

theValue = false;

}

// assuming there actually is such a cookie

if(theValue) {

// set an expired cookie, adding 'path' and 'domain' if they were given

document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'');

}

}



//******************* API **********************



//Checks for the existence of anchors.

//If none exist, returns false so this Action is grayed out.


function canAcceptBehavior(){

return true;

}




//Returns Javascript functions to be inserted in HTML head with script tags.


function behaviorFunction(){

return "WM_killCookie";

}



//Returns fn call to insert in HTML tag <TAG... onEvent='thisFn(arg)'>

//Gets list of cookieValues from doc attribute. With each cookieValue, it gets the parallel

//anchor name from select 'menu'. Each cookieValue & anchorObj are embedded as args.


function applyBehavior(uniqueName) {

var i,argList="";


if (document.WM_cookieName) { //if not empty

//xxx

argList = "'" + document.WM_cookieName + "','" + document.WM_cookiePath + "','" + document.WM_cookieDomain + "'";


return "WM_killCookie("+argList+")"; //return fn call with args

} else {

return MSG_NoCookieValueSet;

}



}



//Given the original function call, this parses out the args and updates

//the UI. Loops through each anchorObj,cookieValue pair.

//If anchorObj already present in menu, stuff cookieValue in aHrefArray. If anchorObj

//doesn't exist, add to menu, and extend aHrefArray.


function inspectBehavior(behFnCallStr){


var argArray;

argArray = extractArgs(behFnCallStr); //get args

if (argArray.length == 4) {

document.theForm.cookieName.value = argArray[1];

document.theForm.cookiePath.value = argArray[2];

document.theForm.cookieDomain.value = argArray[3];


initializeUI();


} else alert(MSG_WrongNumberOfArgs);

}



//Used to improve performance, this hardcodes the expected window size. Without

//this fn, or if WINDOWSIZE_Autosize is true, DW will render the UI dynamically.

//IMPORTANT: for internationalization and other UI changes, update the globals.



//***************** LOCAL FUNCTIONS ******************


//Load the select menu with current hrefs.

//Also sets the global property WM_myAHrefs to the right num of items.


function initializeUI(){

storeCookieName();

storeCookiePath();

storeCookieDomain();

document.theForm.cookieName.focus(); //set focus on textbox

document.theForm.cookieName.select(); //set insertion point into textbox

}




//Given cookieName in form, looks up the menu's selection number, and stores the

//new href at that position in the global document property "WM_myDivColor".


function storeCookieName(){

var cookieName = document.theForm.cookieName.value;

document.WM_cookieName = cookieName; //rewrite global

}


function storeCookiePath(){

var cookiePath = document.theForm.cookiePath.value;

document.WM_cookiePath = cookiePath; //rewrite global

}


function storeCookieDomain(){

var cookieDomain = document.theForm.cookieDomain.value;

document.WM_cookieDomain = cookieDomain; //rewrite global

}



//**************** GENERIC FUNCTIONS ****************



//Given a function call, extracts the args and returns them in array

//Respects ', skips over stuff between quotes, and returns them dequoted.

//IMPORTANT: argArray[0] is the function call!! Actual args start at argArray[1].


function extractArgs(behFnCallStr){

var i, theStr, lastPos, argArray;


argArray = getTokens(behFnCallStr,"(),");

for (i=0; i<argArray.length; i++) {

theStr = unescQuotes(argArray[i]);

lastPos = theStr.length-1;

if (theStr.charAt(0) == "'" && lastPos > 0 && theStr.charAt(lastPos) == "'")

argArray[i] = theStr.substring(1,lastPos);

}

return argArray

}



//Given a string "myObject *" returns "myObject *".


function stripStar(theStr) {

var endPos;


endPos = theStr.indexOf(' *');

return ((endPos > 0)? theStr.substring(0,endPos) : theStr);

}




//Given theSelect obj and an index, it appends a star

//and inserts the new string into the menu at position index.

//If the menu item was "layer[2]" it becomes "layer[2] *".

//Existing " *" values get stripped off first.


function addStarToMenuItem(theSelect,menuIndex) {

var newMenuText;


newMenuText = stripStar(theSelect.options[menuIndex].text); //remove if old star

newMenuText += " *"; //append " *"

theSelect.options[menuIndex]=new Option(newMenuText); //add new line to menu

}




//Passed a string, finds special chars '"\ and escapes them with \


function escQuotes(theStr){

var i, theChar, escStr = "";

for(var i=0; i<theStr.length; i++) {

theChar = theStr.charAt(i);

escStr += (theChar=='"' || theChar=="'" || theChar=="\\")?("\\"+theChar):theChar;

}

return escStr;

}




//Passed a string, finds any escape chars \ and removes them


function unescQuotes(theStr){

var strLen, i, theChar, unescStr = "";

strLen = theStr.length;

for(i=0; i<strLen; i++) {

theChar = theStr.charAt(i);

if (theChar == "\\" && i < strLen - 1) //if escape char and not end

theChar = theStr.charAt(++i); //append next char and skip over

unescStr += theChar;

}

return unescStr;

}




//Converts an array of JS anchors to an array of their current urls.

//For example, document.links[0] becomes "http://bar.com/foo.html"


function niceNames(objRefArray,objTypeStr) {

var i, j, niceRef, tokens;

var niceNameArray = new Array(objRefArray.length);


for (i in objRefArray) { //with object reference array

tokens = getTokens(objRefArray[i],".").reverse(); //split ref into tokens and rev order

if (tokens.length > 1) {

niceRef = objTypeStr + ' ' + nameReduce(tokens[0]); //start building str

if (tokens.length > 2) { //reference includes some nesting...

if (tokens[1] != "document") //inside a form so add form reference

niceRef += ' ' + TYPE_Separator + ' ' + TYPE_Form + ' ' + nameReduce(tokens[1]);

for (j=1; j<tokens.length; j++) //add any layers

if (tokens[j].indexOf("layers[") == 0) //found a layer

niceRef += ' ' + TYPE_Separator + ' ' + TYPE_Anchor + ' ' + nameReduce(tokens[j]);

}

} else niceRef = objRefArray[i];

niceNameArray[i] = niceRef;

}

return niceNameArray;

}




//Extracts a name or num from array string and quotes if necessary. So

// myImg => "myImg"

// layers['foo'] => "foo"

// embeds[0] => 0

// myImg[2] => "myImg[2]"


function nameReduce (objName) {

var retVal, arrayTokens;


retVal = '"' + objName + '"'; //default is object wrapped in quotes

if (objName.indexOf("[") > 0) { //if it's an array

arrayTokens = getTokens(objName,"[]\"'"); //break up tokens

if (arrayTokens.length == 2) { //if exactly two tokens

if ("layers forms embeds links anchors all".indexOf(arrayTokens[0]) != -1) { //if legal

if (arrayTokens[1] == ""+parseInt(arrayTokens[1])) //if a number

retVal = arrayTokens[1];

else //else it's a string

retVal = '"' + arrayTokens[1] + '"';

}

}

}

return retVal;

}




//Emulates printf("blah blah %s blah %s",str1,str2)

//Used for concatenating error message for easier localization.

//Returns assembled string.


function errMsg() {

var i,numArgs,errStr="",argNum=0,startPos;


numArgs = errMsg.arguments.length;

if (numArgs) {

theStr = errMsg.arguments[argNum++];

startPos = 0; endPos = theStr.indexOf("%s",startPos);

if (endPos == -1) endPos = theStr.length;

while (startPos < theStr.length) {

errStr += theStr.substring(startPos,endPos);

if (argNum < numArgs) errStr += errMsg.arguments[argNum++];

startPos = endPos+2; endPos = theStr.indexOf("%s",startPos);

if (endPos == -1) endPos = theStr.length;

}

if (!errStr) errStr = errMsg.arguments[0];

}

return errStr;

}


function displayHelp() {

if (typeof window != 'undefined') window.open("http://www.webmonkey.com/") ;

}



//*************** END OF JAVASCRIPT *****************


function MM_popupMsg(theMsg) { //v1.2

alert(theMsg);

}

//-->

</SCRIPT>

 

Содержимое этой таблицы поместите между <BODY> и </BODY>

 

<body onLoad="initializeUI()">










<FORM NAME="theForm" ACTION="">

<DIV ALIGN="center">

<TABLE BORDER=0 bgcolor="#808080">

<tr> 

<td valign="top" rowspan="4"> 

&nbsp;

</td>

<td valign="top" align="left" colspan="3">
<p align="center"></font><font face="Arial Black, Arial, Helvetica, sans-serif" color="#FF0000" size="4">Убить
куки...&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></p>
<p align="center">&nbsp;</p>
</td>

</tr>

<tr> 

<TD ALIGN="right" nowrap><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Cookie 

Name:</font></TD>

<TD VALIGN="top" nowrap> 

<font size="3" color="#FFFFFF">

<INPUT NAME="cookieName" TYPE="text" SIZE="30" onBlur="storeCookieName();" value="myCookie">

</font>

</TD>

</TR>

<TR> 

<TD ALIGN="right" nowrap><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Path:</font></TD>

<TD VALIGN="top" nowrap> 

<font size="3" color="#FFFFFF">

<INPUT NAME="cookiePath" TYPE="text" SIZE="30" onBlur="storeCookiePath();">

</font>

</TD>

</TR>

<TR> 

<TD ALIGN="right" nowrap><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Domain:</font></TD>

<TD VALIGN="top" nowrap> 

<font size="3" color="#FFFFFF">

<INPUT NAME="cookieDomain" TYPE="text" SIZE="30" onBlur="storeCookieDomain();">

</font>

</TD>

</TR>

<font size="3" color="#000000">

<tr> 

<TD>&nbsp; </TD>

<TD colspan="2">
</font>
<font face="Verdana, Arial, Geneva, sans-serif" size="1" color="#FFFFFF">This 

function deletes the specified cookie from the current document's cookie 

file. If a PATH or DOMAIN was specified when the cookie was set, they 

must be specified in order to delete the cooke as well.&nbsp;

</font></TD>

</tr>

</TABLE>

</DIV>


</FORM>

Назад в раздел Cookie

Note. Для выделения используйте Ctrl+Click, для копирования Ctrl+C или меню после клика правой кнопкой мыши. Скопированные скрипты сначала поместите в любой текстовый редактор, например, в Блокнот, и только затем, скопировав вновь, вставляйте в код страницы.


Используются технологии uCoz