Prat824 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks I have been trying to link an external css to my run mode but have been unsuccessful so far. I have tried three ways of doing it 1. directly in template file like so..

<LINK REL=StyleSheet href="file:///C:/Program Files/Apache Software Fo +undation/Apache2.2/cgi-bin/myapp/templates/basic.css" TYPE="text/css" + MEDIA=screen>

2. declared as template var in runmode and used TMPL_VAR in path above in template file

sub browse : Runmode { my $self = shift; my $template = $self->load_tmpl("browse_form.html"); $template->param (CSS => 'file:///C:/Program Files/Apache Software + Foundation/Apache2.2/cgi-bin/linkmotor/templates/basic.css'); + return $template->output; }

3. Declated in runmode like so..

$self->query->start_html( -style => {'src'=>'http://www.mystyle.com/st +yles/style.css'} );

The problem is that when I view source in the first 2 ways, I see the linking with css path and when I copy source and save it as a dummy html file, it works - the styles take over. Why then it doesn't recognize css via calling the runmode? Thanks in advance for your help.

Replies are listed 'Best First'.
Re: CGI::Application run mode does not recognize external css
by Corion (Patriarch) on Apr 19, 2010 at 14:44 UTC

    Try to eliminate as many contributing causes as possible.

    Have you looked at the HTML your code creates? Is the link to your stylesheet in there or not? Can you use a plain CGI object to create the HTML you want?

      As I said, I saved the html source that my code generates as a separate html file and that seems to recruit the external css just fine.

        Well, if you refuse to show the HTML generated for the first solution that works, and the HTML generated for the second solution that fails, then it will be quite hard to determine why the one works while the other does not.

        My guess is that the URL does not work, at least http://www.mystyle.com/styles/style.css does not work for me. But feel free to try other approaches to finding out why this does not work.

        Have you checked your webservers logs? I doubt it's serving this css file, and in your test case your browser is just picking it up from the path in the html.