2010-09-23 105 views
1

获取弹出窗口的打开窗口我们正在运行一个点击通话服务,我的想法基本上是这样的:网站在他们的页面上有一个链接,当链接被点击时,在我们的服务器上托管的一个网页(称为popup.aspx)是弹出式的,用户可以输入他们的电话号码,并点击“打电话给我”按钮让网站给他打电话。在按钮点击事件中,我想获取Request.UrlReferrer,然后查询数据库以获取网站的电话。但在IE浏览器中,Request.UrlReferrer为null(firefox没问题,还没有测试Chrome),我的问题是如何在IE中打开窗口的url?IE浏览器:如何使用window.open(url)

我们把我们的服务器上popup.aspx因为

  1. 我们的客户的网站没有强制使用asp.net。

  2. 我们可以控制我们在弹出窗口中放置的内容,并且可以从我们这边修改页面,如果我们将弹出窗口放在合作伙伴的一侧,如果我们有100个合作伙伴,并且我们更改页面的设计,我们会通知他们每个人都进行更改,更改...

  3. 我们可以实现一个静态系统,知道如何弹出一个日子,这网站是最流行的,等

回答

1

你有没有尝试window.opener.location.href(在JavaScript中)?

您也可以在开头器中用javascript调用pageMethod以从您的(服务器端查询)取回CSS并将其应用到您的页面。

Link

Popup.aspx

<form id="form1" runat="server"> 
<asp:ScriptManager EnablePageMethods="true" runat="server"></asp:ScriptManager> 
<div> 

<script> 
    function call() { 
     var location = window.opener.location.href;  
     PageMethods.GetPhoneNumber(location, clientcall); 
    } 

    function clientcall(phone){ 
     alert(phone); 
    } 

</script> 
<a href="javascript:call();">Call</a> 
</div> 
</form> 

Popup.aspx.cs

使用系统; using System.Collections.Generic;使用System.Linq的 ; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Services;

public partial class Popup : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 

    } 

    [WebMethod] 
    public static string GetPhoneNumber(string referer) 
    { 

//把你的代码中调用此数据库 回报 “888-888-888”; }}

调用页面

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title></title> 
</head> 
<body> 
<script> 
    function opening() { 
     window.open("Popup.aspx","mywindow", "status=1,toolbar=1"); 
    } 
</script> 
<a href="#" onclick="opening()">Ouvrir</a> 

</body> 
</html> 
相关问题