• 利用window.location.href取URL值及Session来判断是否满足条件


    前台页面的后台加载时给个Session ,

    Session["keycode"] = "Guankan";

        protected void Page_Load(object sender, EventArgs e)
        {
            Session["keycode"] = "Guankan";
            lblSum.Text = Application["count"].ToString();
            if (Convert.ToInt32(lblSum.Text) >= 100)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script languge='javascript'>alert('已经有"+lblSum.Text+"位同事在观看了,请稍候在观看,谢谢配合!');window.location.href='menu_sc.html'</script>");
            }
            
        }

    后台页面的后台来判断是否有接收到Session,
    没有就返回,有就继续执行语句。

        protected void Page_Load(object sender, EventArgs e)
        {
            
    
            if (Session["keycode"] == null || Session["keycode"].ToString() != "Guankan")
            {
                Response.Redirect("index.html");
            }
        }

    前台Javascript判断URL路径,

    <script type="text/JavaScript">
        setTimeout(detectEnd, 3000);
    
        function detectEnd() {
            if (document.getElementsByTagName("video")[0].src == "") {
                setTimeout(detectEnd, 3000);
            }
            else {
                if (document.getElementsByTagName("video")[0].addEventListener) {
                    document.getElementsByTagName("video")[0].addEventListener('ended', myHandler, false);
                }
                else {
                    document.getElementsByTagName("video")[0].attachEvent('ended', myHandler, false);
                }
                function myHandler(e) {
                    window.location.href = "sign.aspx?success=1";
                }
            }
        }
    </script>

    录入页面获取后判断是否有含字段,

    <script language="javascript" type="text/javascript">
            var url = window.location.href;
            if (url.toString().indexOf("success") == -1) {
                alert("您还没有观看视频,请重新观看再录入,谢谢!");
                window.location.href = "index.html";
            }
     </script>
  • 相关阅读:
    centos 配置静态ip
    mysql常用命令
    mac 安装好mysql后密码重置
    安装Intellij Idea14/15
    freemarker 学习一 入门小例子
    获取类路径
    mysql中的int smallint 取值范围
    MySQL按照汉字的拼音排序
    Log4j 基本配置
    追加写入
  • 原文地址:https://www.cnblogs.com/iDennis/p/5670913.html
Copyright © 2020-2023  润新知