addStyleSheetはスタイルシートを追加するJavaScriptの関数です。2次元の連想配列を引数にして使用します。
ダウンロード : addstylesheet.zip
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>addStyleSheet.js - Sample Code</title>
<script type="text/javascript" src="addStyleSheet.js"></script>
<script type="text/javascript">
addStyleSheet({
'#box': {
'width': '200px',
'height': '100px',
'border-radius': '10px',
'background-color': '#f80',
'color': '#fff',
'font-weight': 'bold',
'line-height': '100px',
'text-align': 'center'
},
'#box:hover': {
'background-color': '#08f'
}
});
</script>
</head>
<body>
<div id="box">addStyleSheet.js</div>
</body>
</html>