Link to home
Start Free TrialLog in
Avatar of controltheweb
controltheweb

asked on

Write CSS background filename from current page filename string

On a page this-is-the-filename.htm, I want the background of a style on the page to be this-is-the-filename.jpg. The image filename (without extension) needs to match the page filename (without extension),

alsadu.dreamhosters.com/furniture/furniture_test.htm has embedded style

#pic a {
      background: url('/furniture/images/Trunk_test.jpg');
      width: 320px; height:320px;
      display: block; margin: 0;      padding: 0;       }
#pic a:hover {
      background: url('/furniture/images/Trunk_test.jpg') 0 -320px; }

The string Trunk_test.jpg is what I want to be furniture_test.jpg, taking "furniture_test" from the filename furniture_test.htm
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of controltheweb
controltheweb

ASKER

I think you're right, server side is probably the way to go. Had promised the client to avoid that, but maybe time for an exception.
Zvonko's solution is almost exactly like the server side solution.  You should try with that if you believe the site's users will have JavaScript.

- Joe P