Getting Stylesheets to Work in CGI

J

Jake Timms

I work with a server that does not have FrontPage server
extensions; consequently, I write my own CGI Perl scripts.
I create the basic HTML form in FrontPage, upload to my
UNIX machine and wrap the HTML code in appropriate CGI
code. The only problem I seem to be having is that the
stylesheets clearly aren't being accessed by the script.
I know this to be true because when I cut and pasted the
necessary CSS file into my Perl script as a style block,
it worked fine with one exception: the css file reference
to pictures (.jpg files) as background doesn't seem to
work. The line in the style section is simply:

url ("picture.jpg")

I assumed as long as picture.jpg was in the same directory
as the Perl script, the Perlscript should be able to find
it. I've changed "picture.jpg" to the full path name
(http://www/server/cgi-bin/myfiles/) to no avail.

Any assist would be appreciated.
 
S

Steve Easton

Try hyphens instead of quotes.
background-image: url('picture.jpg')


--
Steve Easton
MS MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
 
J

Jim Buyens

So, your style sheet looks like one of these, right?

<STYLE>
BODY { background:
url("http://www/server/cgi-bin/myfiles/picture.jpg") }
</STYLE>

or

<STYLE>
BODY { background: url("picture.jpg") }
</STYLE>

If so, do other pictures in the same folder display
correctly? For example, does
<img src="picture.jpg">
show up OK?

<STYLE>
BODY { background:
url("http://www/server/cgi-bin/myfiles/picture.jpg") }
</STYLE>

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
J

Jake Timms

Sorry, I typed the wrong thing. The background reference
is already exactly as you stated, that is:

background-image: url('picture.jpg')

After I sent my last message, I thought I might insert
a "require" statement (i.e., require "picturefile.css";)
in my Perl script. That didn't work. Would a server side
include (SSI) statement work or am I going off into the
weeds?
 
J

Jake Timms

Sorry, I typed the wrong thing. The background reference
is already exactly as you stated, that is:

background-image: url('picture.jpg')

After I sent my last message, I thought I might insert
a "require" statement (i.e., require "picturefile.css";)
in my Perl script. That didn't work. Would a server side
include (SSI) statement work or am I going off into the
weeds?
 
J

Jake Timms

Sorry, I typed the wrong thing. The background reference
is already exactly as you stated, that is:

background-image: url('picture.jpg')

After I sent my last message, I thought I might insert
a "require" statement (i.e., require "picturefile.css";)
in my Perl script. That didn't work. Would a server side
include (SSI) statement work or am I going off into the
weeds?
 
J

Jake Timms

Actually, I'm not using a style sheet, I'm using a style
block within my CGI Perl script. I would much prefer to
use a style sheet but, for some reason, I couldn't get my
script to locate it. So I copied the HTML style code from
the style sheet and stuck it into a style block in my
program. That style block looks like this (exactly as it
appears the code):

body { font-family: verdana, Arial, Helvetica; background-
image: url('sumtextb.jpg')}

The code is direct lift from the sumi painting FrontPage
theme.

I had no other pictures on the page, so I put two in to
test your theory(?) using:

<img src = "sumtextb.jpg">
<img src = "mypic.gif">

The first was the background from FrontPage I'm trying to
show while the other is a non-FrontPage picture just in
case the FrontPage stuff was somehow corrupted.

Neither picture showed on the page when I looked at it via
a browser, but a "placeholder" for each one did show up.
(You know, a square with an "X" to signify the picture
couldn't be shown.) I don't know if it matters, but I'm
using IE 6.0.
 
S

Steve Easton

You need to terminate the background image reference
with a semicolon
body {
font-family: verdana, Arial, Helvetica;
background- image: url('sumtextb.jpg');
}

hth

--
Steve Easton
MS MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
 
J

Jim Buyens

OK. If you right-click one of those "missing" pictures and choose
Properties, the resulting dialog box will show you the URL the browser
was looking for. If your HTML was:

<img src="sumtextb.jpg">

and the browser was looking for

http://www.muserver.com/cgi_bin/sumtextb.jpg

they you know the "current" folder is /cgi_bin/ and you can construct
relative paths from that starting point.

This should also help you construct relative paths to style sheets and
other content.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top