Good day!

There is a small script to add css properties for each menu item.

$(document).ready(function () { var icon = [ 'images/okna.png', 'images/portal.png', 'images/ico3.png', 'images/zabor.png', 'images/navesi.png', 'images/s.png', 'images/ico-2.png', 'images/ico4.png', 'images/ico7.png', 'images/ico8.png', 'images/ico9.png' ]; $('li a').each(function (e) { $(this).css({ 'color': 'red', 'background': '#414141 url("' + icon[e] + '")' }) }) }) 

Tell me why the pictures are displayed only on the main page (index.php)?

    3 answers 3

    Because the paths are relative. Once the main page is displayed, just add a slash at the beginning.

    • '/images/ico9.png' is it? does not work at all - woland
    • then lay out everything about your configuration. And even better - show. - Syabrowka

    The script must be connected on every page. Check it out. And the way here, I'm pretty sure, nothing to do with. Is that you have all the directories rastykano.

    • on every page for sure. - woland
    • If the site uses CNC, then just the same and! - Palmervan 7:44 pm
    • If CNC is used, then slashes may not help. There is already a need to look at what they wrote in .htaccess. Perhaps under the schedule there is a rule - Deonis

    '/images/ico9.png' is it? does not work at all

    It looks like you placed the script not in the root folder of the site, so it’s natural that the paths do not work. In this case, the script can be changed as follows:

     var RD = '/path/to/script/'; var icon = [ 'images/okna.png' // ... ]; // ... $(this).css({ 'color': 'red', 'background': '#414141 url("' + RD + icon[e] + '")' }); 
    • does not work - I even moved it to the root directory for the sake of interest - the same thing - woland
    • show me your site already. And then some kind of mystery gives. But for any mystic there is always a reasonable explanation. So show me. This will help find an explanation and solution to your problem. - Syabrowka
    • Played with htaccess, put:> RewriteCond% {HTTP_REFERER}! ^ $> RewriteCond% {HTTP_REFERER}>! ^ Http (s)?: // (www.? Example.com [NC]> RewriteRule \. (Jpg | jpeg | png | gif) $ -> [NC, F, L] Does not display, remove - all Nice) where where example.com understands another domain - Palmervan
    • in fact, the site is on my joomla - I connect the scripts via index.php. so I can throw off the site of course, but this is somewhat problematic. Maybe the fact that the main page I have index.php and other pages index.php / page? - woland
    • It may well be that in this. Joomla is certainly quite an amateur, but your problem hardly depends on the cms used. You just need to clean up the paths. At you the script substitutes in css addresses of pictures and applies this css. Pictures at the same time are displayed only on the main one. Relative paths. What pictures is he looking for on other pages? http requests where to send? It's not about cms at all. Show the site - one quick glance by the web inspector (or httpfox) - and the right answer is in your pocket. In the meantime, we guess at the coffee grounds. - Syabrowka 1:16 pm