问题:怎么在登录验证成功后弹出div
请大侠帮忙写出代码!login.aspx页面有一个登录按钮
<input type="button" id="btnlogin" value="登陆" onclick="checklogin()" />
登录成功后弹出div提示登录入口(两个链接一个进入A一个进入B)
//js验证方法。
var xmlHttp;
function checklogin() {
var u = document.getElementById("username").value;
if (u == "") {
alert("对不起,用户名不能为空");
return false;
}
var p = document.getElementById("password").value;
if (p == "") {
alert("对不起,密码不能为空");
return false;
} if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
xmlHttp = new XMLHttpRequest();
} var now = new Date();
var number = now.getSeconds() % 43;
var number2 = Math.floor(Math.random() * 99999);
var t = number + number2;
var parames = "u=" + u + "&p=" + p + "&save=" + document.getElementById("savelogin").value;
xmlHttp.open("POST", "checklogin.aspx?t=" + t, true);
xmlHttp.setRequestHeader("content-length", parames.length);
xmlHttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
ajaxloader_finish();
if (xmlHttp.status == 200) {
var result = xmlHttp.responseText;
if (result != "-1") {
window.location.reload();
}
else {
alert("对不起,用户名或密码错误");
}
}
} };
xmlHttp.send(parames);
ajaxloader_start();}弹出div方法以写好
var size = { width: 0, height: 0 };
window.onresize = function() {
//debugger
size.width = document.documentElement.clientWidth + "px";
size.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
onWindowResize(size);
}
function onWindowResize(size) {
var _bg = document.getElementById("mybody");
if (!_bg) return;
_bg.style.width = size.width;
_bg.style.height = size.height;
}
function showdiv() {
var w = document.createElement("div");
w.setAttribute("id", "mybody")
with (w.style) {
position = 'absolute';
zIndex = '10000';
width = Math.max(document.documentElement.scrollWidth / 2, document.documentElement.clientWidth / 2) + "px";
height = Math.max(document.documentElement.scrollHeight / 2, document.documentElement.clientHeight / 2) + "px";
position = "absolute";
left = '25%';
top = '65';
background = '#000000';
filter = 'Alpha(opacity=70)';
opacity = '0.7';
}
document.body.appendChild(w);
//**********************************************//
var ig = document.createElement("div"); ig.innerHTML = '<h1>请选择你要管理的产品:</h1><br/><a href="configuration.aspx"><img title="配置Item条件" src="images/2636.jpg"/> /<a href="default.aspx"><img title="数据管理" src="images/3013.jpg"/></a>';
document.getElementById("mybody").appendChild(ig);
with (ig.style) {
position = 'absolute';
zIndex = '10001';
left = '50%';
top = '25%';
marginLeft = -ig.offsetWidth / 2 + 'px';
marginTop = -ig.offsetHeight / 2 + 'px';
}
document.body.appendChild(ig);
}
请大侠帮忙写出代码!login.aspx页面有一个登录按钮
<input type="button" id="btnlogin" value="登陆" onclick="checklogin()" />
登录成功后弹出div提示登录入口(两个链接一个进入A一个进入B)
//js验证方法。
var xmlHttp;
function checklogin() {
var u = document.getElementById("username").value;
if (u == "") {
alert("对不起,用户名不能为空");
return false;
}
var p = document.getElementById("password").value;
if (p == "") {
alert("对不起,密码不能为空");
return false;
} if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
xmlHttp = new XMLHttpRequest();
} var now = new Date();
var number = now.getSeconds() % 43;
var number2 = Math.floor(Math.random() * 99999);
var t = number + number2;
var parames = "u=" + u + "&p=" + p + "&save=" + document.getElementById("savelogin").value;
xmlHttp.open("POST", "checklogin.aspx?t=" + t, true);
xmlHttp.setRequestHeader("content-length", parames.length);
xmlHttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
ajaxloader_finish();
if (xmlHttp.status == 200) {
var result = xmlHttp.responseText;
if (result != "-1") {
window.location.reload();
}
else {
alert("对不起,用户名或密码错误");
}
}
} };
xmlHttp.send(parames);
ajaxloader_start();}弹出div方法以写好
var size = { width: 0, height: 0 };
window.onresize = function() {
//debugger
size.width = document.documentElement.clientWidth + "px";
size.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
onWindowResize(size);
}
function onWindowResize(size) {
var _bg = document.getElementById("mybody");
if (!_bg) return;
_bg.style.width = size.width;
_bg.style.height = size.height;
}
function showdiv() {
var w = document.createElement("div");
w.setAttribute("id", "mybody")
with (w.style) {
position = 'absolute';
zIndex = '10000';
width = Math.max(document.documentElement.scrollWidth / 2, document.documentElement.clientWidth / 2) + "px";
height = Math.max(document.documentElement.scrollHeight / 2, document.documentElement.clientHeight / 2) + "px";
position = "absolute";
left = '25%';
top = '65';
background = '#000000';
filter = 'Alpha(opacity=70)';
opacity = '0.7';
}
document.body.appendChild(w);
//**********************************************//
var ig = document.createElement("div"); ig.innerHTML = '<h1>请选择你要管理的产品:</h1><br/><a href="configuration.aspx"><img title="配置Item条件" src="images/2636.jpg"/> /<a href="default.aspx"><img title="数据管理" src="images/3013.jpg"/></a>';
document.getElementById("mybody").appendChild(ig);
with (ig.style) {
position = 'absolute';
zIndex = '10001';
left = '50%';
top = '25%';
marginLeft = -ig.offsetWidth / 2 + 'px';
marginTop = -ig.offsetHeight / 2 + 'px';
}
document.body.appendChild(ig);
}
完全看不出这是.NET的东西
c.focus();
c.onclick();
你要把控件ID传到js里??
用隐藏字段来传,你可以直接在后台调用js方法,一起把ID传过去
functiion A(id)
{
}
在JS中弹出DIV或jwindow弹出
document.getElementById(id).style.dislpay="block";//显示
请大侠帮忙写出代码!
var obj=document.getElementById("div");
if(obj!=null){
obj.style.display=obj.style.display==""?"none":"";
}
function showKeyPress() {
var act = document.activeElement.id;
var c=null;
if(act=='UserCode' && event.keyCode==13 && document.getElementById('UserCode').value.length>0 )
{
document.getElementById('UserPass').focus();
return false;
}
else if(act=='UserPass' && event.keyCode==13 && document.getElementById('UserPass').value.length>0)
{
c = document.getElementById('imgLogin');
c.focus();
c.onclick();
var obj=document.getElementById("ma");
if(obj!=null){
obj.style.display=obj.style.display=="none"?"":"none";
}
return true;
}
else
{
if(event.keyCode==13 && document.getElementById('UserCode').value.length>0)
{
document.getElementById('UserPass').focus();
return false;
}
} }
document.onkeypress = showKeyPress看一下行不