没关系,实际上它很简单:
$('html').attr('style', strStyle);
完整示例:
<script type="text/javascript" language="javascript">
function SetScrollbarStyle()
{
with (document.frmCustomize)
{
var strStyle = 'scrollbar-arrow-color: ' + arrow.value + ';' + "\n" + 'scrollbar-base-color: ' + base.value + ";\n" + 'scrollbar-dark-shadow-color: ' + darkshadow.value + ";\n" + 'scrollbar-track-color: ' + track.value + ";\n" + 'scrollbar-face-color: ' + face.value + ";\n" + 'scrollbar-shadow-color: ' + shadow.value + ";\n" + 'scrollbar-highlight-color: ' + highlight.value + ";\n" + 'scrollbar-3d-light-color: ' + light.value + ";";
code.value = '<style type="text/css">' + "\n" + 'html {' + "\n" + strStyle + "\n}" + "\n" + '</style>' + "\n";
//$('body').css('background-color', '#ff0000');
//$('body').css(strStyle);
//$('body').attr('style', strStyle);
$('html').attr('style', strStyle);
}
}
</script>
从表单按钮 onclick 事件调用 SetScrollbarStyle 的位置。