简体   繁体   English

Chrome和Firefox列出样式图像

[英]Chrome and Firefox list-style-image

Let's say I have the following code: 假设我有以下代码:

var doc = document.implementation.createHTMLDocument("");               
doc.body.appendChild(doc.createElement("ul"));
doc.getElementsByTagName("ul")[0].style["listStyle"] = "square inside url('image.png')";
console.log(doc.getElementsByTagName("ul")[0].style["listStyleImage"]);

In Internet Explorer, I get: 在Internet Explorer中,我得到:

url("image.png") 

However, on Firefox (sometimes) and Chrome, I get: 但是,在Firefox(有时)和Chrome上,我得到:

url()

Any advise? 有什么建议吗?

I am not sure why do you have to handle it this way. 我不确定为什么要这样处理。 But if you use the full url to the image it should work: 但是,如果您使用图像的完整网址,则它应该可以工作:

var doc = document.implementation.createHTMLDocument("");               
doc.body.appendChild(doc.createElement("ul"));
doc.getElementsByTagName("ul")[0].style["listStyle"] = "square inside url(http://www.example.com/image.png)";
console.log(doc.getElementsByTagName("ul")[0].style["listStyleImage"]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM