为什么这段JavaScript程序 IE老说有问题

来源:百度知道 编辑:UC知道 时间:2024/09/23 23:18:33
<!--
程序如下
其中FrmInfor是一个表单,
LyrMoveFg和LyrMoveBg是两个Div层.
Txt起头的是文本框.
问一下为什么有错???
-->

<script language="JavaScript">
<!--
function show()
{
//standard information
document.FrmInfor.ImgBg.src=document.FrmInfor.TxtBgSrc.value;
document.FrmInfor.ImgBg.width=document.FrmInfor.TxtBgWidth.value;
document.FrmInfor.ImgBg.height=document.FrmInfor.TxtBgHeight.value;
document.FrmInfor.ImgFg.src=document.FrmInfor.TxtFgSrc.value;
document.FrmInfor.ImgFg.width=document.FrmInfor.TxtFgWidth.value;
document.FrmInfor.ImgFg.height=document.FrmInfor.TxtFgHeight.value;
//extended information
var LyrMoveFg=document.getElementbyId(LyrFg);
var LyrMoveBg=document.getElementbyId(LyrBg);
LyrMoveFg.hspace=document.FrmInfor.TxtFgLeft.value;
LyrMoveFg.vspace=document.FrmInfor.TxtFgTop.value;
LyrMoveBg.hspace=document.FrmInfor.TxtBgLeft.value;
LyrMoveBg.vspac

你只说IE下不行,那FF,OPERA下有没有试过呢?如果没有,建议你先杂FF下用FireBugs插件检查一下有没有程序以及单词拼写方面的错误,比如你这里明显getElementById就写错了,然后再到IE下去看看真正的错误是什么再发上来.
单独看你这段代码思路是没有问题的~~可能是环境以及拼写等细节方面的错误,不一定是IE下独有的

楼主你实现的功能是你图片的各项属性=你表单输入的各个值吗,都加个sytle,如document.FrmInfor.ImgBg.sytle.width试试,src就不要变了,

//必须有style="position:absolute;z-index:10" 这一句
<div id="div1" style="position:absolute;z-index:10">sd<div>

//然后可以用这样设置层的位置
document.getElementById('div1').style.left=document.FrmInfor.TxtFgLeft.value;

getElementbyId
大小写
getElementById

document.getElementById("LyrFg");
document.getElementById("LyrBg");