• Cookies (VBScript vs. JavaScript)

    Home » Forums » Developers, developers, developers » Web design and development » Cookies (VBScript vs. JavaScript)

    • This topic has 1 reply, 2 voices, and was last updated 23 years ago.
    Author
    Topic
    #371076

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #588832

      That won’t be hard at all. You can use the following code to read a cookie (Name = Cookie Name):

      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))
            }
         }
      }

      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%5B/url%5D

    Viewing 0 reply threads
    Reply To: Cookies (VBScript vs. JavaScript)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: