利用js动态创建一个link插入到文档中, 请求css文件,利用 computedStyle = window.getComputedStyle 获取指定元素的 style 对象,利用 computedStyle .content 获取内容
CSST (CSS Text Transformation)
@keyframes anima {
from {}
to {
opacity: 0;
}
}
@-webkit-keyframes anima {
from {}
to {
opacity: 0;
}
}
#CSST {
content: "${text}";
animation: anima 2s;
-webkit-animation: anima 2s;
}
function handle () {
var computedStyle = getComputedStyle(span, false);
var content = computedStyle.content;
console.log('content: %s', content);
var match = content.match(/[\w+=\/]+/);
// base64解码
if (match) {
try {
content = decodeURIComponent(escape(atob(match[0])));
} catch (ex) {
fn(ex);
return;
}
}
return content
}
var CSST = document.getElementById('CSST');
//监听事件
CSST.addEventListener('animationstart', handler, false);
CSST.addEventListener('webkitAnimationStart', handler, false);