0

I have a website which specify's a background image from the CSS.

The client has asked us if it would be possible to have different backgrounds for each page (category technically). let call their site clients.com

Unfortunately we don't own the website, simply manage it for a client and as such have very limited access... We can update the CSS but not much in the way of HTML (or .aspx technically).

My idea was, we may be able to specify the background image source from somewhere else, perhaps another server at resources.clients.com Ideally the other server would return different images based on the URL which requested the data. Perhaps I'd have a database of URLs and the returned image file, with unspecified URLs loading a default...

Any thoughts on how this might be achieved, or other suggestions would be greatly appreciated. I am intrigued about how this could be done on a personal level, not just for this project/clients sake.

Thanks :D

1 Answer 1

1

I'm afraid your idea won't work. There are several reasons for that. The request for resources mentioned within a style sheet file is made by the page visitor's browser. This browser won't send any information on which page was visited.

You'd be better off asking the developers of the application to add category specific CSS classes to the body of the page. So you can define according styles.

Another reason why your approach won't work is browser caching. Referencing one image in a CSS file without any other information will make the browser cache this file (I suppose caching headers are not disabled on the application server). So when the visitor is heading for another category page, the browser will still serve the picture loaded for the previous category.

Sign up to request clarification or add additional context in comments.

1 Comment

yea i'd consider problems with resource caching, thought it might be my downfall... Appreciate that a style sheet is interpretted locally, but it has to look for (lets say) background.png, and thought there may be a way of returning different file versions based on requested page. But I appreciate it won't sent the page url without a post header or something. In which case it would need to reference a .php file to request the resourse or something weird and wonderful I guess

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.