相关疑难解决方法(0)

用JavaScript获取图像数据?

我有一个带有一些图像的常规HTML页面(只是常规的<img />HTML标签).我想得到他们的内容,优选base64编码,而不需要重新下载图像(即它已经被浏览器加载,所以现在我想要内容).

我很想用Greasemonkey和Firefox实现这一目标.

javascript firefox base64 greasemonkey image

326
推荐指数
6
解决办法
41万
查看次数

你如何用JavaScript阅读CSS规则值?

我想返回一个包含CSS规则所有内容的字符串,就像您在内联样式中看到的格式一样.我希望能够在不知道特定规则中包含的内容的情况下执行此操作,因此我不能仅通过样式名称将其拉出(如.style.width等)

CSS:

.test {
    width:80px;
    height:50px;
    background-color:#808080;
}
Run Code Online (Sandbox Code Playgroud)

到目前为止的代码:

function getStyle(className) {
    var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules
    for(var x=0;x<classes.length;x++) {
        if(classes[x].selectorText==className) {
            //this is where I can collect the style information, but how?
        }
    }
}
getStyle('.test')
Run Code Online (Sandbox Code Playgroud)

html javascript css

106
推荐指数
5
解决办法
11万
查看次数

标签 统计

javascript ×2

base64 ×1

css ×1

firefox ×1

greasemonkey ×1

html ×1

image ×1