网页显示后一段时间后显示,如果选择“咨询”,则弹出来聊天窗口。如果选择“稍后再说”,则窗口消失,但是过一段时间又弹出来

 
<%@ 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">
    <title></title>
    <script>
        function getPosition() {
            var top = document.documentElement.scrollTop;
            var left = document.documentElement.scrollLeft;
            var height = document.documentElement.clientHeight;
            var width = document.documentElement.clientWidth;
            return { top: top, left: left, height: height, width: width };
        }

        function showPop() {
            var width = 300; //弹出框的宽度 
            var height = 160; //弹出框的高度 
            var obj = document.getElementById("pop");

            obj.style.display = "block";
            obj.style.position = "absolute";
            obj.style.zindex = "999";
            obj.style.width = width + "px";
            obj.style.height = height + "px";

            var Position = getPosition();
            leftadd = (Position.width - width) / 2;
            topadd = (Position.height - height) / 2;
            obj.style.top = (Position.top + topadd) + "px";
            obj.style.left = (Position.left + leftadd) + "px";

            window.onscroll = function () {
                var Position = getPosition();
                obj.style.top = (Position.top + topadd) + "px";
                obj.style.left = (Position.left + leftadd) + "px";
            };
        }

        function hidePop() {
            document.getElementById("pop").style.display = "none";
            setTimeout('showPop()', 3000);
        }
        function newopen() {
            window.open('newopen.aspx','','width=300px,height:200px;top:100px,left:200px');
        }
        setTimeout('showPop()', 3000);

</script> 
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div id="pop" style="border:1px solid #CCC;display:none; background-color:Yellow">欢迎您的光临<br>
        <input id="Button1" type="button" value="咨询" onclick="newopen()" />   <input
            id="Button2" type="button" value="稍后再说" onclick="hidePop()" />
    </div>
    </form>
</body>
</html>

你可能感兴趣的:(server,function,XHTML,咨询,聊天,button)