Javascript/CSS/PHP all rolled into one...
Moderator: General Moderators
Javascript/CSS/PHP all rolled into one...
I have a style chooser on my site which is a php session variable, what this then does is it will import whichever style the user wants. The thing is that when I do this, i want to somehow declare javascript variables in those css files... is there any way to do this? if not... can it easily and effeciently be done in another fashion? Thanks in advance...
you cant really use js in a css file, but its easy to make a dynamically generated js file:
yes it is possible to get values from the stylesheet using js, but its not trivial imo
i think "easily and efficiently" could only be answered depending upon the context and extent of your desired use.
Code: Select all
<?php
if ($stylesheet == 'foobarbaz') {
$jsvar = 'bar';
}
if ($jsvar == 'foo') {
echo 'var jsvar = "foo"';
} else {
echo 'var jsvar = "bar";
}
?>i think "easily and efficiently" could only be answered depending upon the context and extent of your desired use.