Member Sign In
Not a member?

A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.


It's fast and free.

Sign in with OpenID
Sign In
Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
processing...

Retrieve Sign In

Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

Isolate Cookies

/skill level/
/viewed/
0 Times

Here's some (slightly simplified) code taken from Thau's Advanced JavaScript Tutorial that allows you to isolate a specific cookie.



function WM_readCookie(name) {


if (document.cookie == '') {


// there's no cookie, so go no further


return false;


} else {


// there is a cookie


var firstChar, lastChar;


var theBigCookie = document.cookie;


firstChar = theBigCookie.indexOf(name);


// find the start of 'name'


if(firstChar != -1) {


// if you found the cookie


firstChar += name.length + 1;


// skip 'name' and '='


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


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


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


return unescape(theBigCookie.substring(firstChar, lastChar));


} else {


// If there was no cookie of that name, return false.


return false;


}


}

}


// WM_readCookie

Code and Explanation

The Tags



HTML - This tells the browser this is a HTML document. Put the start tag, <HTML>, at the beginning of your document and the end tag, </HTML>, at the bottom of your document.

  <HTML> Put your whole document in here. </HTML>

TITLE - Every page should have a title. The title will appear as the window title.

  <TITLE>My Web Site</TITLE>

BODY - This lets you specify the colour of the background or lets you put a graphic in the background. Colours have to be specified in hexadecimal format, which is kind of confusing, but we included some samples below. To change the background colour use ���bgcolor��� to change the colour of the text use ���text���. At the end of your page, include the closing </BODY> tag.

  <BODY bgcolor="ffffff" text="3344cc">
  <BODY background="pretty_graphic.gif">
P - Indicates a paragraph. You should use both the opening

tag and the closing

tag.

This is the beginning of a new paragraph.

And this is the next paragraph.

FONT - Controls the size, colour, and typeface of the text. Size is controlled by increasing or decreasing the text���s normal size. Size="+2" would increase the font by two and size="-2" would decrease it by two. ���Face��� is used to change to a different font, but be warned that you, or the person reading your page, will have to have the font installed for it to display properly.

  Text goes here
  Text
  Text

B, I, U - To make text bold, italics, or underlined.

  Bold me, please
  Aren���t italics nice
  Underline is nice too

IMG - Used to include a graphic on your page. The browser will look for a graphic in the same directory (or folder) as your web page file is in, so make sure that���s where your graphics are.

    Although it isn���t necessary, it is a good idea to include the width and height (in pixels) of the graphic. If you don���t know the size, leave it out altogether. The IMG tag also allows you to add a border to the graphic using ���border���. For a border one pixel thick, use border="1".
  The IMG tag doesn���t have a close tag.
  <IMG width="100" height="25" SRC="my_graphic.gif">
  <IMG border="1" SRC="my_photo.jpeg">

A HREF - This will make a ���hot��� link to other pages, sites, or email. You can also make a graphic ���clickable��� by embedding an <IMG> between the start and end tags.

  <A HREF="http://myspace.com/steven1steve">YES Mag</A>
  <A HREF="otherpage.html">My other page</A>
  <A HREF="intruda333@aim.com">Send us email</A>
  <A HREF="http://www.yesmag.ca"><IMG SRC="yesmag_logo.gif"></A>


Bold text

  • This page was last modified 01:52, 24 October 2008.
Edit this article
Reddit Digg
 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year