Paul McFedries' Web Home


Here is the image you requested (see the explanation, below):

This page uses a JavaScript program to get the cookie that was set in the boilerplate-images2.asp page. This cookie contains the name of the full-size graphics file to load on this page. The script writes the appropriate <IMG> tag on-the-fly.

To set this up, you must do two things:

  1. Add the following code between the </HEAD> and <BODY> tags:
    <SCRIPT LANGUAGE = "JavaScript">
    <!--
    function GetCookie(name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
            var j = i + alen;
            if (document.cookie.substring(i, j) == arg)
                return GetCookieVal (j);
            i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0) break; 
            }
        return null;
    }
    
    function GetCookieVal (offset) {
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1)
            endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
    }
    //-->
    </SCRIPT>
    
  2. Insert the following code at the spot where you want the image to appear:
    <SCRIPT LANGUAGE = "JavaScript">
    <!--
    //
    // Get the cookie
    //
    var img = GetCookie("Image")
    if (img != "") {    
        //
        // Write the <IMG> tag using the name of the graphics 
        // file (you may need to adjust the SRC text)
        //
        document.write('<IMG SRC="' + img + '">')
    }
    //-->
    </SCRIPT>
    

Copyright © 1995-2008 Paul McFedries and Logophilia Limited