js兼容问题请教 弹层效果
<form name="frm" action="links.asp?action=AddLinks" method="post" style="margin:0px;"><table width="100%" cellpadding="0" cellspacing="0">
<tr><td align="right" width="70"><strong>网站名称:</strong></td>
<td align="left" style="padding:3px;"><input name="link_name" type="text" class="userpass" id="link_name" size="50"/>
<span class="red"> *</span></td>
</tr>
<tr><td align="right" width="70"><strong>网站地址:</strong></td><td align="left" style="padding:3px;"><input name="link_URL" type="text" size="50" class="userpass" value="http://"/>
<span class="red">*</span></td>
</tr><td align="right" width="70"><strong>E-mail:</strong></td>
<td align="left" style="padding:3px;"><input name="link_Email" type="text" class="userpass" id="link_Email" size="50"/>
<span class="red">*</span></td></tr>
<tr><td align="right" width="70"><strong>网站Logo:</strong></td><td align="left" style="padding:3px;"><input name="link_Logo" type="text" class="userpass" id="link_Logo" size="50"/></td></tr>
<tr>
<tr><td align="right" width="70"><strong>验证码:</strong></td><td align="left" style="padding:3px;"><input name="Code" type="text" class="userpass" id="Code" size="4" maxlength="4" />
<span id="getcode"><img src="Code.asp?',Math.random(),'" alt="看不清,请点击刷新验证码" id="newimg" style="cursor:pointer" onClick="refreshimg()">点击图片刷新验证码</span></td>
</tr>
<tr><td align="right" width="70"></td><td align="left">提示:网站的Logo和地址要写完整,必须包含 http://</td></tr>
<tr>
<td colspan="2" align="center" style="padding:3px;"><input name="submit" type="submit" class="userbutton" value="提交链接" onclick="javascript:return CheckPost();" />
<input name="button" type="reset" class="userbutton" value="重写" /> </td>
</tr>
</table>
</form>
表单代码。。html <input name="submit" type="submit" class="userbutton" value="提交链接" onclick="javascript:return CheckPost();" /> 提交按钮。。
表单判断代码:
function CheckPost()
{
if(document.frm.link_name.value=="")
{
//alert("请填写你的网站名称");
msgbox("网站名称不能为空");
return false;
}
if(document.frm.link_URL.value=="http://" || document.frm.link_URL.value=="")
{
//alert("请填写你的网站域名(网址)");
msgbox("网站域名不能为空");
return false
}
if(document.frm.link_Email.value=="")
{
//alert("请填写你的联系邮箱,乐乐的审核会发信通知到你的邮箱");
msgbox("E-mail不能为空");
return false;
}
if(document.frm.Code.value=="")
{
//alert("请填写验证码");
msgbox("请填写验证码");
return false;
}
}
弹层代码:
window.onresize=function()
{
document.getElementById("layer").style.height = document.documentElement.scrollHeight + "px";
document.getElementById("layer").style.width = document.documentElement.scrollWidth + "px";
}
function msgbox(info)
{
//创建一个遮罩层,半透明
//------------------我是谁?我是割线!-----------------//
var msg = document.createElement("div");
msg.id = "layer";
with(msg.style)
{
width = "100%";
height = document.documentElement.scrollHeight + "px";
background = "#000000";
position = "absolute";
left = "0";
top = "0";
filter = 'Alpha(opacity=70)';
opacity = '0.7';
}
document.body.appendChild(msg);
//创建一个提示框..
//------------------我是谁?我是割线!-----------------//
var Alert = document.createElement("div");
Alert.id = "MessageBox";
Alert.innerHTML = '<div style="background:url
(skins/default/images/alert.gif);height:186px;"><br><br><br><br><br>' + info + '<br><br><br><br><br><input
type="button" value="关闭" onclick="Close()" style="width:50px;height:30px;" /></div>';
with(Alert.style)
{
position = "absolute";
left = "37%";
top = document.documentElement.scrollTop + window.screen.height / 4 + "px";
width = "312px";
height = "186px";
}
document.body.appendChild(Alert);
//隐藏网页中所有的下拉框//
//------------------我是谁?我是割线!-----------------//
for(i=0;i<document.all.tags('select').length;i++)
{
var obj=document.all.tags('select')[i];
obj.style.display = "none";
}
}
function Close()
{
document.body.removeChild(document.getElementById("layer"))
document.body.removeChild(document.getElementById("MessageBox"))
for(i=0;i<document.all.tags('select').length;i++)
{
var obj=document.all.tags('select')[i];
obj.style.display = "";
}
}