WebKit Engine의 스타일 시트에 프로그래밍 방식으로 액세스하는 방법 (Chrome/Safari)
-
05-09-2019 - |
문제
문서가 포함 된 즉, getElementById ( "CSS_ID"). 스타일 시트
또는 Firefox document.getElementById ( "CSS_ID"). 시트
나는 스타일 시트 객체를 조작 할 수 있지만 크롬 및 사파리 브라우저에서 그 속성은 없습니다.
그 개체를 어떻게 얻을 수 있습니까?
감사
해결책
errr, 내 테스트에서. 시트는 잘 작동합니다 - 내 테스트 케이스는
<html>
<head>
<style id="styleElement"></style>
<link id="linkElement" data="data:text/css," rel="stylesheet"></link>
<script>
window.onload=function() {
alert(["<style element>.style: " + document.getElementById('styleElement').sheet,
"<link element>.style: " + document.getElementById('linkElement').sheet])
}
</script>
</head>
</html>
Safari 3.2에서만 테스트했으며 Webkit Nightlies에서만 테스트했으며 Chrome은 Safari 3.1의 Webkit 만 사용하지만 3.1에서 3.2 사이의 엔진 변경이 있다고 생각하지 않습니다.
제휴하지 않습니다 StackOverflow