解决AJAX弹出窗口被浏览器拦截的问题

原创|其它|编辑:郝浩|2012-09-05 14:30:23.000|阅读 1155 次

概述: 常常遇到AJAX弹出的窗口被拦截的问题,这里通过JS和.NET代码完美实现全弹出窗口。

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>

 常常遇到AJAX弹出的窗口被拦截的问题,这里通过JS和.NET代码完美实现全弹出窗口。

代码:

 

<%@ 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>Untitled Page</title>
<script language ="javascript">
function getAjaxXml()
{  var xml = new ActiveXObject("Microsoft.XMLHTTP");
        var str="flag=888";
xml.open("GET","showXML.aspx?"+str,false);
xml.send();
return xml.responseText;
}
function imgclick()
{
var value=getAjaxXml();
window.open ("http://www.asp.net/?xml="+value );
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="button" onclick="imgclick();"/>
</div>
</form>
</body>
</html> <!-- showXML.aspx --> <%@ Page Language="C#" AutoEventWireup="true" CodeFile="showXML.aspx.cs" Inherits="showXML" %> <!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>


 

//showXML.aspx.cs using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class showXML : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{
Response.Write("xml" + Request["flag"]);
}
}
Edit:
the blod line with yellow back ground cause the program is not supported by Firefox

That is because Firefox is not support Microsoft.XMLHTTP, you can use the following code to create xml variable:

var xml; {  xml =new ActiveXObject("Msxml2.XMLHTTP") } catch(e) { try {  xml=new ActiveXObject("Microsoft.XMLHTTP"); } catch(oc) {  xml=null; }


 


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP