Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    USA
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cookies (VBScript vs. JavaScript)

    If I use VBScript to write a non-persistent cookie that contains 5 or 6 values,

    How hard will it be to have Javascript read the data in the cookie for use on other pages?

    Or am I just asking for more aggravation?

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cookies (VBScript vs. JavaScript)

    That won't be hard at all. You can use the following code to read a cookie (Name = Cookie Name):<pre>function getCookie(Name) {
    var search = Name + "="
    if (document.cookie.length > 0) { //if there are any cookies
    offset = document.cookie.indexof(search)
    if (offset != -1) { //if cookie exists
    offset += search.length
    //set index of beginning of value
    end = document.cookie.indexof(";", offset)
    //set index of end of cookie value
    if (end == -1)
    end = document.cookie.length
    return unescape(document.cookie.substring(offset, end))
    }
    }
    }</pre>

    I suggest you check out Netscape's Client-Side JavaScript Guide (1.3) and Client-Side JavaScript Reference (1.3). You can also download these in PDF version at http://developer.netscape.com/tech/javascr...javascript.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •