OK... I'm sure I'm missing something obvious here... but how do I call a 
function (or maybe variable) from within a 'document.write' statement?

I've written a script that uses document.write to generate a global 
stylesheet declaration when a page is opened, based on the value of a 
cookie previously set by the user.

This works fine, but I have one variable that is to be written in by a 
second cookie, in this case the 'text-decoration' value for 'A:link'.  So 
here's what I have at the moment:

function links () {

        linkline = GetCookie('linkline')

        if (linkline == "line") {
        document.write ("underline");

[snip] 

This works fine when I call it from the body of the document, i.e., 
<script>links()</script> -- the correct value for the 'linkline' cookie is 
written to the screen. So I know the cookie is being set and retrieved 
correctly.  The next section of the script writes the stylesheet stuff to 
the document head:

style = GetCookie('style') 

if (style == "style1") {

        document.write   
        ("<style 'type=text/css'> <!-- ");

        document.write 
        ("body { background-color: #ffffff }");

        document.write 
        ("A.link {color: #ffffcc; text-decoration: ???? }");

Etc.  So where the "????" is above I want to write in the string returned 
by GetCookie('linkline'), but I just can't make it happen.  Or whether it's 
even possible to write to an existing 'document.write' statement.  Or what 
the hell.  Sigh.

Just as I start to think I'm getting a handle on Javascript, I invariably 
stumble across gaping holes in my basic knowledge of the language.  
Gotta get myself a book on it sometime, I guess :)

Suggestions from any of you progammer mavens out there?

-----------
Brent Eades, Almonte, Ontario
   E-mail: [EMAIL PROTECTED]
           [EMAIL PROTECTED]
   Town of Almonte site: http://www.almonte.com/
   Business site: http://www.federalweb.com

____________________________________________________________________
--------------------------------------------------------------------
 Join The Web Consultants Association :  Register on our web site Now
Web Consultants Web Site : http://just4u.com/webconsultants
If you lose the instructions All subscription/unsubscribing can be done
directly from our website for all our lists.
---------------------------------------------------------------------

Reply via email to