function Insert(sPrompt,i)
{
var sURL = prompt(sPrompt, "");
if (sURL)
{
document.forms[i].picurl.value=sURL
}
return;
}
function DisabledKeyInput()
{
event.returnValue=false;
}
function CheckLogoRadio(i)
{
//var i=0;
if (document.forms[i].RadioW[0].checked)
{
document.forms[i].button1.disabled=false;
document.forms[i].button2.disabled=true;
}
else if (document.forms[i].RadioW[1].checked)
{
document.forms[i].button1.disabled=true;
document.forms[i].button2.disabled=false;
}
}
//zhf
//--------------------------------
var img=null;
function s(n)
{
i=n;
if(img)img.removeNode(true);
img=document.createElement("img");
img.attachEvent("onreadystatechange",orsc);
img.attachEvent("onerror",oe);
img.src=document.forms[i].upfile.value;
}
function oe()
{
alert("上传图片类型为:GIF、JPEG/JPG、BMP");
document.forms[i].button1.disabled=true;
}
function orsc()
{
nLimFileSize=document.forms[i].picsize.value;
nLimWidth=document.forms[i].picwidth.value;
nLimHeight=document.forms[i].picheight.value;
if(img.readyState!="complete")
{
return false;
}
else if(img.width>nLimWidth||img.height>nLimHeight)
{
alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!");
document.forms[i].button1.disabled=true;
}
else
{
document.forms[i].button1.disabled=false;
}
}
博客展示了多个JavaScript函数。Insert函数用于获取用户输入的URL并赋值给表单;DisabledKeyInput函数禁用按键输入;CheckLogoRadio函数根据单选框状态禁用按钮;还有用于图片上传检查的函数,能判断图片类型、大小是否符合要求。
230

被折叠的 条评论
为什么被折叠?



