Is it possible to use SVG images as CSS background?

need to get website to remember background with a cookie or something.

  • if you go to: http://www.thesmartass.info/ , at the bottom of the page there are a bunch of numbers. If you click on those numbers it will swap an external css file which will change the background of the website. What i want it to do is somebody clicks that number and it sets a cookie or something that when they return to the website it remembers which css file they had clicked on last. The code to set the css goes like this: <a href="#" target="_self" onclick="document.styleSheets(0).href='/css/css2.css'";>2, </a>. If this code needs to be replaced or just modified doesn't matter to me so long as it achieves my objectives. If you can answer that and you can tell me how to put that line into an iframe and have it switch the css file for a different frame without reloading the website i will give a decent tip. (example, if you go to the above listed website and click on customize at the bottom of the page you will see that clicking the color schemes changes the page colors but if you click the images at the top it does as well however it does not effect the non iframe that is below it.) For reference I use, html, javascript, php, css, sql for my website. _.,-*~'^^'~*-,.__.,-*~'^ saagnyL semaJ www.thesmartass.info _.,-*~'^^'~*-,.__.,-*~'^

  • Answer:

    Hi, Here is a simple-ish PHP implementation that will allow the cookie-stored CSS theme to be accessed throughout the site, like so: Put the folling code in a file (I'd call it cookie.php): --- BEGIN --- <?php if (!empty($settheme)) { $theme = $settheme; setTheme(); } elseif (!empty($_COOKIE['theme'])) { $theme = $_COOKIE['theme']; } elseif (!empty($killcookie)) { killCookie(); } function setTheme() { global $theme; setcookie('theme',$theme,time()+2678400,'/','thesmartass.info'); } function getTheme() { global $theme; $default_theme = "css.css"; $css_dir = "./css/"; // trailing slash is important. $css_path = "cas/"; // here too. $css_prefix = "css"; $css_suffix = ".css"; if (!empty($theme)) { $cssfile = $css_prefix.$theme.$css_suffix; if (!file_exists($css_dir.$cssfile)) { $cssfile = $default_theme; } } else { $cssfile = $default_theme; } return $css_path.$cssfile; } function killCookie() { setcookie('theme','',time()-2678400); } ?> --- END --- Now, at the top of each page (which needs to be php passed) before any HTML is output, you should add: <?php include("cookie.php"); ?> Replace your CSS link with: <link rel="stylesheet" type="text/css" href="<?php echo getTheme(); ?>"> And the CSS links should be: <a href="<?php echo $PHP_SELF; ?>?settheme=1">1</a> (etc...) And if you'd like to create a link to clear theme cookies, add something like: <a href="<?php echo $PHP_SELF; ?>?killcookie=1">Clear Themes</a> Try it out and let me know if you have any feedback about it, as there are a number of minor changes that can be made to alter it's operation. As for the reloading the contents of the frame, the easiest way to do that, is rather than just loading the contents of a frame using the traditional 'target=' method, write a simple handler: <?php if (empty($page)) { $page = "links" } ?> <iframe [...] src="/<?php echo $page; ?>.php"></iframe> This way, your News link changes to: <a href="index.php?page=news">News</a> It means the main page has to reload, but it also makes the content of that page linkable within the frameset. Furthermore, you can add a Javascript to force the page to be loaded in the frameset if it is loaded on it's own. This is especially handy when you consider that your content may well be indexed on search engines without the frameset context. I hope this helps, let me know if you have any problems. I haven't run this code specifically, but have written similar code many times in the past, and that code did pass a basic syntax checker. Regards, sycophant-ga

trimidium-ga at Google Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.