3 replies [Last post]
eSite
Offline
Regular
Last seen: 16 years 19 weeks ago
Timezone: GMT+1
Joined: 2004-07-12
Posts: 14
Points: 0

Hi,

My site has Google AdSense and users are able to choose LOTS of (css) styles and even create their own.

So I would need the AdSense JS to dynamically use the values of the properties of the selectors of the CSS file (hope it's clear to you).

Example :

Here's the normal code from AdSense :

google_color_bg = "00ff00";

I would like it to be :
google_color_bg = "<?php echo $pineapple:?>";

according to :

http://domain.com/banana.css

.pineapple {
  color: #00ff00;
  }

Notes :
All values to fetch are hexadecimal colors.
There is only one property per selector.

1) How do I fetch these values ?
2) How do I remove the # from them ?

Thx by advance.

Tags:
_janim
Offline
Regular
phinland
Last seen: 16 years 24 weeks ago
phinland
Joined: 2004-06-08
Posts: 22
Points: 0

Fetching property's value of CSS selector.

Check this topic at webmasterworld.com
http://www.webmasterworld.com/forum91/1954.htm

For stripping the # from a color value, this is an easy way:

function strip(val)
{
   // strip the first character from string
   val = val.substring(1);
   return val;
}

Please Provide a link to your code/site. If you can't, then please at least provide the HTML & CSS together.

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 4 years 43 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Fetching property's value of CSS selector.

If you're trying to fetch them from the CSS file and 'print' them in the HTML, that won't work. PHP scripting (as you've used there) won't automatically read in the CSS file!

I guess you #could# make it read in the file, set up some arrays, so you could get at the values... seems an awful lot of effort though...

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

eSite
Offline
Regular
Last seen: 16 years 19 weeks ago
Timezone: GMT+1
Joined: 2004-07-12
Posts: 14
Points: 0

Fetching property's value of CSS selector.

Ah, okay, that's why nobody answered me on all the forums where I did post.
Fortunately it seems possible with javascipt, which is the language used for AdSense.