开发者

Perl CGI script with css

I am using a external css for my CGI web form but I can't get the .css to take to the page. Is there a certain way a external css needs to be called. I tried:

<link rel="stylesheet" type="text/css" href="../styles/archiveRequest.css" media="screen" />

which has not been worki开发者_StackOverflow中文版ng. I have tried moving the css in the same folder as the .cgi with still no results.


The href attribute needs to be in relation to the page you're viewing in your browser. For example, if your URL is http://www.example.com/cgi-bin/mypage.cgi then, with your above code, your CSS file needs to be viewable in a browser at http://www.example.com/styles/archiveRequest.css. Try loading it up directly in your browser using the direct URL. Also take a look at your server logs, and you'll probably find 404 errors showing where the file is trying to be loaded from.


If you were "able to load the /styles/archiveRequest.css", then use "/styles/archiveRequest.css" as href too.


I know this was asked quite a while ago, but I had the same problem today and spent hours looking for an answer. This is what worked for me:

If my cgi script is /var/cgi-bin/test.cgi, putting my style.css file in the same directory did not work. Apparently this makes it get treated like a script, which it isn't. I moved my style file to /var/www/styles/style.css and made it non-executable (but readable).

In a browser, I was able to see it at localhost/styles/style.css, so in my cgi script I referenced it as:

my $stylesheet = "/styles/style.css"; start_html(-style=>{'src'=>$stylesheet}), ....

Hope this is useful to someone else.

(The answer that helped me was found here: http://forums.devnetwork.net/viewtopic.php?f=1&t=113842)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜