Response.Write("<script>alert('弹出对话框!')</script>") 后跟Response.Redirect("page.aspx");不能弹出对话框,直接跳转页面了 如何解?
2024-10-18 07:17:50
Response.Write和Response.Redirect一起用的时候就会这样,write脚本和redirect脚本不能同时使用,这样不会执行脚本,最好使用ClientScript
改进方法:
方法一:
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language=javascript >alert('弹出对话框!');</script>");
Response.Redirect("page.aspx");
方法二:
Response.Write("<script>alert('弹出对话框!');window.location.href = 'page.aspx';</script>");
方法三:
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language=javascript >alert('弹出对话框!');window.location.href = 'page.aspx';</script>");
最新文章
- 安装ArcGIS Engine 9.3
- jquery div 下拉框焦点事件
- Bash命令积累
- java基础—继承题目:编写一个Animal类,具有属性:种类;具有功能:吃、睡。定义其子类Fish
- NopCommerce功能与特点介绍
- vi-11
- Know How To Use ID_NULL Function To Search An Object In Oracle Forms
- Http中Cookie和Session介绍
- OpenJudge 2757 最长上升子序列 / Poj 2533 Longest Ordered Subsequence
- Google Map API v2 步步为营 (二)----- Location
- WebGL文字渲染的那些问题
- Union和Union All 的区别
- php curl 跨域情趣
- Mysql5.5安装
- ";Linux内核分析";第七周
- bzoj千题计划198:bzoj1084: [SCOI2005]最大子矩阵
- CAS (8) —— Mac下配置CAS到JBoss EAP 6.4(6.x)的Standalone模式(服务端)
- Distributed3:SQL Server 分布式数据库性能测试
- PHP面试系列之Linux(一) ----- Linux基础
- Python Pygame (2) 事件