<script language="JavaScript">
<!-- Activate cloaking device
document.write('<body background="' + image + '" >')
// Deactivate cloaking device -->
</script>我需要在背景上加上这个额外的样式。
不重复中心固定
我试过了,但没有用:
document.write('<body background="' + image + '" no-repeat center center fixed>')如何将此样式添加到背景中?
发布于 2012-09-17 14:37:15
哇,这是一个古老的剧本。脚本周围的注释已经不需要很长时间了,language属性被type属性所取代。
要将这些CSS设置添加到样式中,必须使用CSS样式而不是background属性:
<script type="text/javascript">
document.write('<body style="background: url("' + image + '") no-repeat center center fixed">');
</script>使用脚本写出正文标记可能会对搜索引擎查看页面的方式产生不良影响。最好像往常一样创建body元素,然后在其上设置样式:
<body>
<script type="text/javascript">
document.body.style.background = 'url("' + image + '") no-repeat center center fixed';
</script>发布于 2012-09-17 14:34:58
问题是您没有使用好的语法:
document.write('<body style="background:url("' + image + '") no-repeat center center fixed;">');发布于 2012-09-17 14:36:56
document.getElementsByTagName('body').style.background = 'url("' + image + '") no-repeat center center fixed';https://stackoverflow.com/questions/12461524
复制相似问题