前台页面的后台加载时给个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>