我想在css
更改时添加具体的url
:
示例:
example.org/43-product.html#/2-size-s/11-color-black/28-modele-coffee
当我在我的网站上选择属性时,url
会发生变化,就像我选择了white color
一样,会给我:
example.org/43-product.html#/2-size-s/8-color-white/28-modele-coffee
我希望在选择黑色时选择背景,为白色和每种可能的组合选择其他背景。
我用这个函数来检查网址
<script type="text/javascript">
$(document).ready(function () {
if(window.location.href.indexOf("franky") > -1) {
alert("your url contains the name franky");
}
});
</script>
但是只有当我刷新页面时它才有效,有没有办法使它工作,以便网址更改而不进行任何刷新?
答案 0 :(得分:0)
您可以将style.css
保存为style.css.php
并填写顶部,例如:
<?php
header('Content-type: text/css');
$background_color = htmlentities($_GET['background_color'], ENT_QUOTES, 'UTF-8');
?>
/* CSS code goes here */
......或类似的东西。请注意,代码仅作为示例提供,并且不安全(如果设置了颜色,颜色存在则丢失...)