js getdocumentbyid.getElementById("s").style.background="url(./images/icons/64/computer.png)&qu

&&国之画&&&& &&
版权所有 京ICP备号-2
迷上了代码!document.getElementById(...)为空或不是对象 行:24_百度知道javascript - document.getElementById.style.backgroundImage not working - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
I want to assign different background images to a div depending on the page's address, so for example, if my url is
I use the following code:
if(document.URL.indexOf("mysubdirectory") &= 0){
document.getElementById("wrapper").style.backgroundImage = "url('bg-wrapper.jpg')";
But it's not working. I even added a bogus document.write command just to make sure the rest of the code was ok and sure enough the bogus line showed up in my browser. Is there something I'm overlooking?
EDIT: Thank you all for your answers - when I use body instead of getElementById("wrapper") in my code, the image shows up, so I doubt it's a path-related issue. I trued adding an onload attribute to the body tag but it's still not working with getElementById. Any ideas?
document.getElementById("wrapper").style.backgroundImage = "url('bg-wrapper.jpg')";
code is correct.
It works fine in this jsfiddle:
Are you sure the image is correct. Remember that the path to the file is relative to the location of the current page. NOT the css directory
129k20187254
7,67132241
Try this, I think the image url is wrong most likely. You probably need a relative path of sorts:
document.getElementById("wrapper").style.backgroundImage = "url('/bg-wrapper.jpg')";
31.8k13113158
I'm using Chrome 29.0.1547.66 and none of the anwers worked either.
So I tried:
document.getElementById("wrapper").style.backgroundImage = "url(http://media.nu.nl/m/m1fz6dwa6h3w.jpg)";
It worked taking off the quotation marks from the image url.
Here working as well:
Specifying a protocol worked for me in chrome. I couldn't get it to work using the catch all '//'. It had to be 'http://' I'm assuming it must match whatever protocol was used to load the page or iframe.
for example
element.style.backgroundImage="url()"
element.style.backgroundImage="url('')"
worked for me.
This works for me:
var pointer =
"url(\'/" + imageArray[imageCounter].toString() + "\')";
document.body.style.backgroundImage = pointer
After spending a bit of time on this, it was the browser's engine parsing the CSS.
No good errors in the console.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled变色杯图片
来源:程序员@跟谁学
//修改图片 function changeLanguage() { var languageNum = document.getElementById(""). window.onload = changeL if (languageNum == '1') { document.getElementById("openaide").style.background = 'url(Images/images_front/Solution.jpg)'; } else { document.getElementById("openaide").style.background = 'url(Images/images_front/Solution_jp.jpg)'; } }...
我相信你一定会好奇地问:“它神奇在哪儿呢, 我拿起这个杯子泡了一杯奶茶, 我一口气把奶茶喝完, 杯子变冷了, 它左边的“心花”是红色的, 奶茶要用很热的水冲, 原本红色的“心花”渐渐变成了棕色, 这是雀巢奶茶的赠品, 这大概是“心花”吧, 你说这花怎么是棕色的呢...
【M站 Nitsqgie 整理报道】, window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg./static/api/js/share.js?v=.js?cdnversion='+~(-new Date()/36e5)];...
public static Bitmap GetWebSiteThumbnail(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight), public WebSiteThumbnail(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight), Bitmap m_B, return m_B, public Bitmap GenerateWebSiteThumbnailImage(), WebBrowser m_WebBrowser = new WebBrowser();, m_WebBrowser.ScrollBarsEnabled =, WebBrowser m_WebBrowser = (WebBrowser), m_WebBrowser.ScrollBarsEnabled =, string m_U...
return HttpResponse('图片为空'), 保存图片中使用到了PIL库, 所以首先要把图片保存在图片对应的文件夹下, 2.上传图片, 如果不加enctype="multipart/form-data:得不到图片信息, 只是保存图片而已, 对图片进行各种操作----参考资料:廖雪峰--PIL, 处理表单的视图会在request中接受到上传文件的数据, return HttpResponse('上传成功'), return HttpResponse('上传失败')...
【变色杯图片】推荐阅读
【变色杯图片】相关问答
这所学校是沈阳医学院何氏视觉科学学院,是2004年由教育部确认批准的按新机制、新模式举办的本科层次的独立学院,其前身为1999年何氏集团与沈阳医学院联合创建的沈阳医学院视光学院。招收高中毕业的学生,就是一所三本院校。学院在沈阳市棋盘山国际风景旅游开发区,网
站: ,你可以去看一下
新修之后水更大更美了,可放书籍;上方是自己的床,那空间~。澡堂水质比外面好。。,采光不错,其它时间免费开发,干净。澡堂除周六不开。偶尔停水另当别论啊,每人有自己的电脑桌,柜子空间足够大,水龙头够用啦。厕所阿姨每天打扫未央6人间,宽敞,电脑桌设有书架。。其次是盥洗室。,我去过一次石油大学新区,宿舍空间不小,旁边有柜子
设窗户一高为x,则宽为(7-2x)/3,按题意得
x(7-2x)/3=2,
下略已知窗户的面积是2平方米,用塑钢做一个窗架,共用去7米。求窗户的长和宽。
设窗户的高为x,那么宽为(7 - 2x)/3,即
x×(7 - 2x)/3 = 2
(2x - 3)(x - 2) = 0
1、当x = x1时,窗户的高为1.5米,宽为(7 - 2×1.5)/3 = 4/3米
2、当x = x2时,窗户的高为2米,宽为(7 - 2×2)
北京电影学院图片摄影专业系列教材共20余本,《摄影色彩构成》、《专题摄影》、《摄影构图》、《风光摄影》、《摄影图片编辑学》、《摄影美学基础》、《素描》、《广告摄影》、《影视摄影》、《摄影作品研究》、《摄影色彩构成》、《专题摄影》、《感光材料应用基础》、《影视短片创作(修订版)》、《报道摄影》、《摄影作品分析》、《曝光技术与技巧》、《现代照相机的原理与使用(修订版)》、《光的造型》、《摄影滤光镜》、
湖南所有的报到证都是一样的,毕业的时候和档案一起走的。一般不允许个人带的!
【变色杯图片】推荐问答
【变色杯图片】推荐搜索
免责声明:本站部分内容、图片、文字、视频等来自于互联网,仅供大家学习与交流。相关内容如涉嫌侵犯您的知识产权或其他合法权益,请向本站发送有效通知,我们会及时处理。反馈邮箱&&&&。
学生服务号
在线咨询,奖学金返现,名师点评,等你来互动

我要回帖

更多关于 background images 的文章

 

随机推荐