X Library Viewer

Download the X Distribution File.

X Index

Animation

xAniLine, xAnimation.arc, xAnimation.corner, xAnimation.css, xAnimation.imgSize, xAnimation.line, xAnimation.opacity, xAnimation.para, xAnimation.rgb, xAnimation.rgbByClass, xAnimation.scroll, xAnimation.size, xAnimation, xAniOpacity, xAniRgb, xAniWH, xAniXY, xEllipse, xParaEq, xSequence, xSlideCornerTo, xSlideTo, xWinScrollTo.

DOM

xFirstChild, xGetElementById, xGetElementsByAttribute, xGetElementsByClassName, xGetElementsByTagName, xLoadLink, xLoadScript, xNextSib, xParent, xParentN, xPrevSib, xSmartLoad, xSmartLoad2, xSmartLoadScript.

Debug

xConsole, xEditable, xName, xParentChain, xSetIETitle.

Event

xAddEventListener, xDisableDrag, xDisableDrop, xEnableDrag, xEnableDrag2, xEnableDrop, xEvent, xHttpRequest, xPreventDefault, xRemoveEventListener, xStopPropagation.

Image

xImgAsyncWait, xImgRollSetup, xTriStateImage.

Iteration

xEach, xEachE, xEachN, xEachUntilReturn, xTimes, xWalkToFirst, xWalkToLast, xWalkTree, xWalkTree2, xWalkTree3, xWalkTreeRev, xWalkUL.

Misc

xCookie, xDef, xDeg, xGetURLArguments, xLibrary, xLinearScale, xNum, xRad, xRound, xStr.

Position

xCardinalPosition, xCen, xCenter, xGetEleAtPoint, xHasPoint, xIntersection, xLeft, xMoveTo, xOffset, xPageX, xPageY, xScrollLeft, xScrollTop, xTop.

Size

xClip, xColEqualizer, xDocSize, xHeight, xResizeTo, xWidth.

String

xCamelize, xCapitalize, xHex, xPad, xParseColor, xRgbToHex, xStrEndsWith, xStrRepeat, xStrReplaceEnd, xStrStartsWith, xTrim.

Style

xAddClass, xDisplay, xFindAfterByClassName, xFindBeforeByClassName, xGetComputedStyle, xGetCSSRules, xGetStyleSheetFromLink, xHasClass, xHasStyleSelector, xHasStyleSheets, xInsertRule, xOpacity, xRemoveClass, xStyle, xTagStyle, xToggleClass, xTraverseDocumentStyleSheets, xTraverseStyleSheet.

Table

xTable, xTableCellVisibility, xTableColDisplay, xTableCursor, xTableCursor2, xTableHeaderFixed, xTableIterate, xTableRowDisplay, xTableSync.

UI

xBar, xCalendar, xCollapsible, xDialog, xFenster, xFenster2, xMenu1, xMenu1A, xMenu1B, xMenu5, xMenu6, xModalDialog, xPopup, xSelect, xSplitter, xTabPanelGroup, xTextArea, xTooltipGroup.

Window

xClientHeight, xClientWidth, xWinClass, xWindow, xWinOpen.

xCookie

Description

Set, get or delete a cookie name/value.

Syntax

see 'methods' below

Source

Default.

// xCookie r2, Copyright 2009 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
var xCookie = {
  get: function(name) {
    var c = document.cookie.match(new RegExp('(^|;)\\s*' + name + '=([^;\\s]*)'));  
    return ((c && c.length >= 3) ? unescape(c[2]) : null);  
  },
  set: function(name, value, days, path, domain, secure) {
    if (days) {
      var d = new Date();
      d.setTime(d.getTime() + (days * 8.64e7)); // now + days in milliseconds
    }
    document.cookie = name + '=' + escape(value) +
      (days ? ('; expires=' + d.toGMTString()) : '') +
      '; path=' + (path || '/') +
      (domain ? ('; domain=' + domain) : '') +
      (secure ? '; secure' : '');
  },
  del: function(name, path, domain) {
    this.set(name, '', -1, path, domain); // sets expiry to now - 1 day
  }
};

Public Methods

xCookie.get(name)Returns a string or null.
xCookie.set(name, value, days, path, domain, secure)name, value, path and domain are strings; days is an integer; secure is a boolean.
xCookie.del(name, path, domain)Sets the value to an empty string and sets expiry to now minus one day.

Demos

toys - Index of all X demos.

Discussions & Tests

6May09viewtopic.php?id=504: Forum topic.

Revisions

2: 29Jul09Added Vic's improvements to the 'set' method.
1: 6May09Initial implementation. A new cookie object to replace the existing xGetCookie, xSetCookie and xDeleteCookie. Thanks very much to Vic! Note that xCookie's "set" method takes an expiry interval in "days relative to today", whereas xSetCookie required an explicit expiry date.

License

By your use of X and/or CBE and/or any Javascript from this site you consent to the GNU LGPL - please read it. If you have any questions about the license, read the FAQ and/or come to the forums.

Tech Support

Forum support is available at the X Library Support Forums.

About Cross-Browser.com

Cross-Browser.com is the home of X - a cross-browser Javascript library, and many demos, applications, articles and documentation.

Search

Cross-Browser.com

World Wide Web

User Projects

If you are using X, XC or anything from this site, show off your work by posting a link in the X Showcase forum.