提示信息窗口的JS实现

提示信息窗口的JS实现

Posted on 2007-04-27 10:22 szw104 阅读(4) 评论(0)   编辑  收藏 引用 网摘 所属分类: AJAX




【前台】


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">

<%--引用外部文件的格式--%>
<%--<link href="../MessageBox.css" rel="stylesheet" type="text/css" />--%>
<%--<script language="javascript" src="../Owner.js" type="text/jscript"></script>--%>


<%--实现Popup功能--%>
<script language="javascript" type="text/javascript">
//Create a popup window
var oPopup = window.createPopup();
var oPopupBody = oPopup.document.body;

oPopupBody.innerHTML 
= '<DIV id="divValidCharMoreInfo"><DIV ID="divValidCharMessage">AX made:</DIV><DIV ID="divValidCharSet"></DIV></DIV>';
oPopupBody.style.backgroundColor 
= "lightyellow";
oPopupBody.style.border 
= "solid black 1px";
oPopupBody.style.padding 
= "3px";

oPopup.document.all(
"divValidCharMessage").style.color = "green";
oPopup.document.all(
"divValidCharMessage").style.fontFamily = "arial";
oPopup.document.all(
"divValidCharSet").style.fontFamily = "arial";
oPopup.document.all(
"divValidCharMessage").style.fontSize = "9px";
oPopup.document.all(
"divValidCharSet").style.fontSize = "9px";
oPopup.hide();


//hide the pop-up window
function OnMouseOutValidCharactersMoreInformation()
{
    oPopup.hide();
}


//show the pop-up window
function OnMouseMoveValidCharactersMoreInformation(charSet, height, width)
{
    
if (!oPopup.isOpen)
    
{
        
var obj = event.srcElement;
//                alert(event.srcElement.innerHTML);
//
                alert(charSet);
        oPopup.document.all("divValidCharSet").innerHTML = "Input the detail info in herre.<br />"+charSet;
//        oPopup.document.all("divValidCharMessage").innerText = "";
//
        alert(obj.parent);
//
                var x = OffsetLeft(obj.parent) + event.clientX;
//
                var y = OffsetTop(obj.parent) + event.clientY + 5;
        var x = event.clientX;
        
var y = event.clientY + 5;
    
//    var width = oPopup.document.all("divValidCharMoreInfo").offsetWidth;
    //    var height = oPopup.document.all("divValidCharMoreInfo").offsetHeight;
        oPopup.show(x, y, height, width, document.body);
    }

    event.cancelBubble 
= true;
}


</script>


<%--Popup功能高级应用JS--%>
<script language="javascript" type="text/javascript">
function clientValidator_AX(AX,zhz)
{
    
if(document.getElementById("TextBox1").value=="AX")
    
{
        zhz.IsValid
=true;
    }

    
else
    
{
        zhz.IsValid
=false;
    }

}

</script>

<%--Popup功能高级应用CSS--%>
<style type="text/css">
.moreInformationValidCharSet
{
    cursor
:hand;
    color
:blue;
    font-family
:arial;
    font-size
:10px;
    text-decoration
:underline
}

</style>

    
<title>Untitled Page</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<span onmousemove="OnMouseMoveValidCharactersMoreInformation('Hello',320,70)" onmouseout="OnMouseOutValidCharactersMoreInformation()">
        
<font color="olive">基本功能演示:鼠标放我上面!</font>
    
</span>
    
<br />
    
<div>
    只有文本框输入的内容为【AX】时,页面才进行PostBack动作!
    
</div>
    
<div>
        
&nbsp;<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>&nbsp;
        
<asp:Button ID="Button1" runat="server" Text="点我" /><br />
        
<asp:CustomValidator ID="CustomValidator_AX" runat="server" ErrorMessage="" ClientValidationFunction="clientValidator_AX" ControlToValidate="TextBox1" Display="Dynamic" ValidateEmptyText="True"></asp:CustomValidator>        
    
</div>
    
</form>  
</body>
</html>

【后台】

【使用】
直接为控件添加两个触发事件就OK了.如下:

< span  onmousemove ="OnMouseMoveValidCharactersMoreInformation('Hello',320,70)"  onmouseout ="OnMouseOutValidCharactersMoreInformation()" >
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值