0

I have page where everything is completed with ajax and php.

I have in-tab content where user can choose colors with color pickers.

When user choose to save his colors, I'm storing new CSS code into database.

here is CSS code

.browser_content{ background-color: #188072; width: 420px; padding-left: 5px; color: #FFFFFF; -moz-border-radius: 5px; border-radius: 5px; webkit-border-radius: 5px; background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#188072), to(#333333)); background: -webkit-linear-gradient(top, #188072, #333333); background: -moz-linear-gradient(top, #188072, #333333); background: -ms-linear-gradient(top, #188072, #333333); background: -o-linear-gradient(top, #188072, #333333); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#188072, endColorstr=#333333); } 


.hotel_location{ background-color: #999999; } 

So when user try open this tab next time, I want to load this css into that page. I've tried to user php headers but nothing happens.

I must notice again, there is no page refresh, content is loaded with ajax, also there can't be new php files which will be used like .css, it must be solved using echo, print or something similar.

Thanks.

1
  • Please show the actual code that you are using to output the custom CSS Commented Dec 16, 2011 at 0:53

2 Answers 2

0

You can use something like this in your php page:

<style type="text/css">
.your_class
{
<?php
    $colorValues = ... // get user's color settings from db
    echo '    color: ' . $colorValue  . ' !important;'
?>
}
</style>;
Sign up to request clarification or add additional context in comments.

Comments

0

Check this out: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml

1 Comment

To add to this anwer, in case it's not obvious, you would create a php script that returns the (contents of) stylesheet (with the right headers) and use its url within the JS Ayman has linked.

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.