Re: Style Sheet Doesn't Display Styles
by Skeeve (Parson) on Jul 19, 2006 at 22:13 UTC
|
| [reply] [d/l] [select] |
|
Hi Skeeve,
- Shift-Reload? Never heard of that. What does that do? I tried it but couldn't see it do anything.
- Empty the Browser's Cache? Is this the same as deleting temporary internet files? I tried that, yes.
- Load the style sheet directly into my browser? Do you mean doing something like this in the address bar? http://127.0.0.1:81/perl/secure/training_site.css
I tried that; it only opens the style sheet inside of an editor.
- View the source page received? Yes, and the HTML code looks fine. In fact copying and pasting the resulting HTM code as it's own HTM file does correctly display the styles.
Thanks for responding.
| [reply] |
|
Despite the fact it didn't help, just a short explanation:
1. Shift-Reload (should) tell the browser not to use the cache.
2. No. Because there might be an In-Memory cache too. But I see: You're using IE!? I have no experience with that. Sorry.
3. Exactly. This is to verify you receive the correct CSS.
4. If this happens when you open the pasted code, then nothing can be wrong - to my understanding - with your code. It must be a caching problem because the only difference is the source where you get your page from.
Try to sniff on the traffic that's going on between your server and your browser and see what they are "talking" about.
But at least try to access your Server from another computer that never visited those URLs...
| [reply] |
Re: Style Sheet Doesn't Display Styles
by jdtoronto (Prior) on Jul 19, 2006 at 20:14 UTC
|
It's all about visibility, or in Perl terms - scope. The page as you generate it expects to see the stylesheet in the same directory as the script, I think if you put a / in front you will force it to look at the root of the webserver ( ie domain.com/stylesheet.css ).
Your not the first person to get tripped up by this, it happened to me some years ago now when we first started using CSS.
jdtoronto | [reply] |
|
Likely as your explanation is, that doesn't explain why the stylesheet get picked up if the $body variable is short and not when it is long.
CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] [d/l] |
|
jdtoronto, thanks for replying.
I'm not sure if that's it, because it is finding the sheet sometimes.
In any case, I tried doing it with the initial slash (also tried an absolute pathway pointing to the .css), but neither improved performance.
I thought it might be a local webserver thing, so I uploaded it and the style sheet to our production server and get the same result.
| [reply] |
|
| [reply] [d/l] |
|
|
|
|
Re: Style Sheet Doesn't Display Styles
by JaredHess (Acolyte) on Jul 19, 2006 at 23:15 UTC
|
Joost,
Regarding your reply and suggestions here...
...I installed livehttpheaders in firefox and checked the headers for both my test perl script and my HTM file using the exact same source code as the perl script:
Perl Header (for the script that doesn't correctly diplay styles)
http://127.0.0.1:81/perl/secure/test.pl
GET /perl/secure/test.pl HTTP/1.1
Host: 127.0.0.1:81
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4
+) Gecko/20060508 Firefox/1.5.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
+,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cache-Control: max-age=0
HTTP/1.x 200 OK
Connection: close
Content-Type: text/html
----------------------------------------------------------
http://127.0.0.1:81/perl/secure/training_site.css
GET /perl/secure/training_site.css HTTP/1.1
Host: 127.0.0.1:81
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4
+) Gecko/20060508 Firefox/1.5.0.4
Accept: text/css,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:81/perl/secure/test.pl
Cache-Control: max-age=0
HTTP/1.x 200 OK
----------------------------------------------------------
HTM Header (For the HTM that correctly displays styles)
http://127.0.0.1:81/perl/secure/test.htm
GET /perl/secure/test.htm HTTP/1.1
Host: 127.0.0.1:81
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4
+) Gecko/20060508 Firefox/1.5.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
+,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.x 200 OK
Transfer-Encoding: chunked
Server: OptiPerl/Commercial
Content-Type: text/html
Connection: close
--------------: ---
----------------------------------------------------------
http://127.0.0.1:81/perl/secure/training_site.css
GET /perl/secure/training_site.css HTTP/1.1
Host: 127.0.0.1:81
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4
+) Gecko/20060508 Firefox/1.5.0.4
Accept: text/css,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:81/perl/secure/test.htm
HTTP/1.x 200 OK
Server: OptiPerl/Commercial
Content-Type: text/css
Connection: close
Content-Length: 1950
----------------------------------------------------------
I've tried both IE and Firefox with indentical results.
I compared the two headers using "Beyond Compare 2" and found that this portion exists in the header for the HTM file that displays correctly, but are missing from the actual perl script file's header:
Server: OptiPerl/Commercial
Content-Type: text/css
Connection: close
Content-Length: 1950
I guess with these items missing the css file doesn't get called correctly. The question is how do I fix this? Is this a server configuration thing?
Thanks for all the help, everyone. I'm seeking further enlightenment. | [reply] [d/l] [select] |
|
| [reply] |
|
Hi shmem, thanks for responding. I think I'm leaning more and more to the view that this is definately a server problem/bug.
For some unknown reason (don't you love it?), the problem unexpectedly went away just as unexpectedly as it manifested itself.
Perhaps it cleared up when I restarted the local server that comes with OptiPerl. If it was something that simple... *smacks forhead*
Perhaps it was something different. I'm still not sure.
I'm going to restart my computer and see if the problem is still there or if it has gone away--hopefully for good.
| [reply] |
|
Re: Style Sheet Doesn't Display Styles
by JaredHess (Acolyte) on Jul 19, 2006 at 21:00 UTC
|
Ok... Another tidbit of information that may shed some light on this.
I changed my script to read as follows:
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
my $body = "123";
my $length = length($body);
my $body2 = "abc";
my $length2 = length($body2);
print<<bob;
<html>
<head>
<!-- Style Sheet Here -->
<link href="./training_site.css" rel="stylesheet" type="text/css">
<title></title>
</head>
<body>
<p class="bodytext">Body variable *$body* has $length chars</p>
<p class="bodytext">Body variable *$body2* has $length2 chars</p>
</body>
</html>
bob
Note that both $body and $body2 are short strings of three chars each. It seems that adding the $body2 into the printed html code makes it so the styles don't display as well. *scratches head* Perhaps the problem is something else and not just long strings?
| [reply] [d/l] |
|
From one of your follow up posts, it sounds like you're getting the desired output (HTML) regardless of the content of the $body variable. If that's the case, this is probably not a perl issue, but a Browser/Server problem as Joost mentions
| [reply] |
|
Hi duckyd, thanks for sharing your wisdom.
You may be correct...Except that I created a .htm page and ran it on the same server in the same folder location as the Perl script, pointing to the same css file, and it functions properly. If it is a Browser/Server problem, shouldn't that fail as well?
Since it only fails using Perl, I suspect something perlish...
...but you may be right. How could I tell for sure?
| [reply] |
|
Can we see your style sheet, please? If I put .bodytext { color: #F00 } in training_site.css, I see both paragraphs in red.
| [reply] [d/l] [select] |
|
Hmm. I wonder if it is a style sheet problem. I didn't even think of that. If so, why would it function in the normal .htm file but not in my Perl script though?
Anwyay, here's the style sheet:
a {
color: #000099;
}
a:hover{
color:#33FF33;
background-color:white;
text-decoration:underline;
}
.smallred {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #CC0000;
}
.smallblack {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color:#000000;
}
.smallblackheading {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color:#000000;
font-weight: bold;
}
.smallredheading {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color:#CC0000;
font-weight: bold;
}
.h1shade {
font-family: Arial, Helvetica, sans-serif;
font-size: 36px;
text-transform: lowercase;
color: #000066;
background-color: #CCCCCC;
}
.h2shade {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
text-transform: lowercase;
color: #330066;
background-color: #CCCCCC;
}
.h3shade {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
text-transform: lowercase;
color:#990000;
background-color: #CCCCCC;
}
.h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 36px;
text-transform: lowercase;
color: #000066;
}
.h2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
text-transform: lowercase;
color: #330066;
}
.h3 {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
text-transform: lowercase;
color:#990000;
}
.bar {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 24px;
color: #000033;
text-transform: lowercase;
background-color: #FFCC00;
border-style: solid;
border-top-width: 3px;
border-left-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-color: #333333;
}
.note {
border-style: solid;
border-top-width: 10px;
border-color:#660033;
}
.bodytext {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color:#000033
font-weight: normal;
border:solid thin yellow;
}
| [reply] [d/l] |
|
|
Re: Style Sheet Doesn't Display Styles
by ikegami (Patriarch) on Jul 19, 2006 at 20:13 UTC
|
The bug is not in what you showed us. The problem is elsewhere. Did you place training_site.css in the same directory as the script? Could it be some caching issue?
| [reply] |
|
ikegami, thanks for the reply.
Yes, the script and the .css are in the same directory. The reason I'm thinking it's something to do with Perl or my code is because I created a straight .htm file that pointed to the .css file using the same generated HTML code and it works fine. It displays styles without problems regardless of the length of what's being displayed.
The .css file is getting called, because, as I stated in my original post, it does sometimes work.
| [reply] |
Re: Style Sheet Doesn't Display Styles
by JaredHess (Acolyte) on Jul 20, 2006 at 17:16 UTC
|
After the system restart things seem to still be working correctly. *breathes a sigh of relief*
*raises hands in praise* To all ye glorious Perl monks who did shine with the brilliance of the sun, and did ever aid to dispell the gloom upon my crestfallen soul, I praise ye your names! May the spirits of the ancients and their mighty wisdom continue to dwell in your hearts!
*Bows deeply with steepled hands to chin and leaves the great hall with the soft rustling of robes*
| [reply] |
|
Perhaps it cleared up when I restarted the local server that comes with OptiPerl
You may wish to check and see whether the "local" HTTPD defaults to caching Perl scripts in memory.
| [reply] |