RE: Getting the body bgColor

by "Brett Errington" <brett(at)opensearch.com>

 Date:  Wed, 6 Feb 2002 09:09:32 +0800
 To:  <hwg-techniques(at)hwg.org>
 In-Reply-To:  yerpso
  todo: View Thread, Original
Hi... 

You can definitely use regular expressions to find the areas on the page
you want to change, however as far as I know, the only way to read the
source code of the page is to use the FSO, you said you didn't want to
do that, why? You don't allow it or what ?

My suggestion is that you make a colour array in the ASP and then
reference that like so all the way down the page:

ColourArray = array("#FFFFFF", "#000000")

<table bgcolor="<%= ColourArray(1)">

I quite often use this and it works great. You could even put the array
in your global.asa file or an include so it was always there.

Later,
Brett

"That's a pain that will shorely linger, and that's no lie" - Ed Grimley
 
-----Original Message-----
From: owner-hwg-techniques(at)hwg.org [mailto:owner-hwg-techniques(at)hwg.org]
On Behalf Of Hank Marquardt
Sent: Wednesday, 6 February 2002 7:33 AM
To: Doug Dossett
Cc: Hank Marquardt; hwg-techniques(at)hwg.org
Subject: Re: Getting the body bgColor

OK, I had to do something similar for a site that was themed (HR pages
were red, FAQs were purple, Department specific stuff was Green) and had
to match both background colors for tables as well as link colors --

In my case each of the areas were in their own directory, so what I did
was take the full path to the script ($PHP_SELF in PHP) and use a regex
to parse out the first level above the scriptname ... ie.
/home/user/www/departments/scriptname.php would be 'departments' and
then I used a switch/case construct to make my color assignments ...
again in PHP:

switch($area) {
	case departments:
		$bgcolor = "#ff6699";
		break;
	case hr:
		$bgcolor = "#9966ff";
		break;
	default:
		$bgcolor = "#999999";
		}

That case construct was in my main code include that was included on
every page of the site so there was just one place to maintain in if the
colors ever changed --- and that is your real exposure here, by not
really grabbing the color on the fly but rather determining it by the
page name you're at the mercy of the designer changing the colors at
some point in time.

Anyway, I'm sure you can do similar things and have similar access to
envrionment variables in ASP, the actaul conversion is left as an
exercise for the reader;)

HTH,

Hank

On Tue, Feb 05, 2002 at 02:49:35PM -0800, Doug Dossett wrote:
> Hello,
> 
> Thanks for the reply.  I wish almost every day I was using PHP for
this site.  
> 
> I have a site navigation with a pop up box for Netscape 4.x users.
This is done partly 
> using a table.  I want to make the table have the same bgcolor as the
page itself.  It 
> seems it should naturally inherit this, but if I don't specify a color
it comes up 
> transparent.  Since different sections of the site have different
bgcolors, I wanted to 
> have it get this info on the fly vs me having to hard code it for each
page.  
> 
> You can see basically the same code at http://www.bastyr.edu, though
the site I'm 
> working on isn't publically available yet.  It's the left hand nav,
and again you have to be 
> using Netscape 4.x to see what I'm talking about. 
> 
> Thanks for any further suggestions. 
> 
> Doug
> 
> 
> On 5 Feb 2002 at 13:10, Hank Marquardt wrote:
> 
> > Only ways that come to mind would be parsing the file, using output
> > buffering and parsing the buffer (you can do this in PHP, not sure
about
> > ASP), outputting all your headers including the BODY tag as part of
a
> > script that controls said color, or inline some scripting to control
the
> > bgcolor (perhaps with a cookie for persistence).
> > 
> > I guess, I'll turn it back on you and ask what outcome you're trying
to
> > achieve? ... then maybe I can come up with more alternatives.
> > 
> > Hank
> > 
> > On Tue, Feb 05, 2002 at 10:30:04AM -0800, Doug Dossett wrote:
> > > Hello all:
> > > 
> > > I don't think this is possible, but I thought I'd ask just in
case. 
> > > 
> > > I'm using ASP with VBScript for server side processing.  I'd like
to be able to get the 
> > > page being loaded's bgColor.  The only way I can see to possibly
get this info is via 
> > > client side JavaScript.  
> > > 
> > > So is there anyway, besides using FSO or something to read the
file and parse it, to 
> > > get the body's bgColor value on the server side?
> > > 
> > > Thanks,
> > > 
> > > Doug Dossett
> > > MiscSites.com
> > 
> > -- 
> > Hank Marquardt <hank(at)yerpso.net>
> > http://web.yerpso.net
> > GPG Id: 2BB5E60C
> > Fingerprint: D807 61BC FD18 370A AC1D  3EDF 2BF9 8A2D 2BB5 E60C
> > *** Web Development: PHP, MySQL/PgSQL - Network Admin:
Debian/FreeBSD
> > *** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild 
> > *** Beginning PHP -- Starts January 7, 2002 
> > *** See http://www.hwg.org/services/classes
> 
> 

-- 
Hank Marquardt <hank(at)yerpso.net>
http://web.yerpso.net
GPG Id: 2BB5E60C
Fingerprint: D807 61BC FD18 370A AC1D  3EDF 2BF9 8A2D 2BB5 E60C
*** Web Development: PHP, MySQL/PgSQL - Network Admin: Debian/FreeBSD
*** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild 
*** Beginning PHP -- Starts January 7, 2002 
*** See http://www.hwg.org/services/classes

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA