Possible Duplicate:
Using Javascript in CSS
is it possible to use javascript codes in css background?
mean something like this :
style=”background:url(javascript:—javascript codes—);”
does this syntax work or not?
thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Technically yes, with an expression:
However I think it only works in IE and it’s very bad practice because it may have to re-evaluate the code hundreds of times every second.
Instead, you should have a suitable default there, and then use JavaScript later on the page to change it.