根据网址的新背景 [英] New background according to url

查看:65
本文介绍了根据网址的新背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以确定根据URL更改背景图像?

Is it possible i'm certain it is, to change a background image according to the url?

例如www.myurl.co.uk/halloween/

For example www.myurl.co.uk/halloween/

如果url包含/halloween/ 然后 正文{background:url(/images/newbackground.jpg)}

if url contains /halloween/ then body {background:url(/images/newbackground.jpg)}

我想我以前曾经做过,但是对于我一生来说,我不记得该怎么做.

I think I have done this before but for the life of me I can't remember how to do it.

首选jQuery?

推荐答案

尝试一下

<script>

    var currentUrl = document.URL;

    if(currentUrl == 'www.myurl.co.uk/halloween/')
      document.body.style.backgroundImage = 'url(/images/newbackground.jpg)';
</script>

这篇关于根据网址的新背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆