jquery跨站点访问变量

时间:2016-08-07 16:15:41

标签: jquery permission-denied cross-site

我有两个不同的应用程序。一个用于博客列表页面另一个用于博客详细信息页面。在点击博客名称时,将使用 window.open 在弹出窗口中打开博客详细信息页面。此博客详细信息来自其他服务器。我必须在博客弹出页面中访问博客列表页面声明的客户端变量。我尝试下面的例子,但它返回权限被拒绝错误。请帮帮我,我需要解决这个问题。

示例:第一个域 http://example.blog.com/bloglist.php

    public void LoopThroughRecs(OleDbDataReader Reader)
    {
        List<int> customer = new List<int>();

        while (Reader.Read())
        {
            int result;

            CustID.Text = Reader["CustID"].ToString();
            FirstName.Text = Reader["Initial"].ToString();
            LastName.Text = Reader["Surname"].ToString();
            Address1.Text = Reader["Address 1"].ToString();
            Address2.Text = Reader["Address 2"].ToString();
            Address3.Text = Reader["Address 3"].ToString();
            TownCity.Text = Reader["Post Town"].ToString();
            PostCode.Text = Reader["Post Code"].ToString();
            Telephone.Text = Reader["Telephone"].ToString();
            LstSvcDat.Text = Reader["LastService"].ToString();
            BoilerMan.Text = Reader["Manufacturer"].ToString();
            BoilerMod.Text = Reader["Model"].ToString();

            result = Convert.ToInt32(CustID.Text);

            customer.Add(int.Parse(CustID.Text));

        }
    }

    public void SearchButton_Click(object sender, EventArgs e)
    {

        System.Data.OleDb.OleDbConnection conn = new
        System.Data.OleDb.OleDbConnection();
        conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BoilerSvc_be.mdb";
        try
        {
            conn.Open();
            OleDbCommand command = new OleDbCommand("SELECT Contacts.CustID AS CustID,CustCode,Initial,Surname,[Address 1],[Address 2],[Address 3],[Post Town],[Post Code],Telephone,Equipment.CustID AS CustID1,Equipment.Manufacturer AS Manufacturer,Equipment.Model AS Model,Equipment.LastService AS LastService FROM Contacts LEFT OUTER JOIN Equipment ON Equipment.CustID = Contacts.CustID WHERE Archived = 0 AND ([Address 1] = '" + textBox12.Text + "' OR CustCode LIKE '" + textBox12.Text + '%' + "' OR Initial = '" + textBox12.Text + '%' + "' OR Surname = '" + textBox12.Text + '%' + "' OR Initial = '" + textBox12.Text + '%' + "' OR [Post Town] LIKE '" + textBox12.Text + '%' + "' OR [Post Code] = '" + textBox12 + '%' + "')", conn);
            OleDbDataReader Reader = command.ExecuteReader();

            LoopThroughRecs(Reader);

        }
        finally
        {
            conn.Close();
        }
    }

    public void NextRecord_Click_3(object sender, EventArgs e)
    {

        System.Data.OleDb.OleDbConnection conn = new
        System.Data.OleDb.OleDbConnection();
        conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BoilerSvc_be.mdb";
        try
        {
            conn.Open();
            OleDbCommand command = new OleDbCommand("SELECT Contacts.CustID AS CustID,CustCode,Initial,Surname,[Address 1],[Address 2],[Address 3],[Post Town],[Post Code],Telephone,Equipment.CustID AS CustID1,Equipment.Manufacturer AS Manufacturer,Equipment.Model AS Model,Equipment.LastService AS LastService FROM Contacts LEFT OUTER JOIN Equipment ON Equipment.CustID = Contacts.CustID WHERE Archived = 0 AND Contacts.CustID <> @CustID AND ([Address 1] = '" + textBox12.Text + "' OR CustCode LIKE '" + textBox12.Text + '%' + "' OR Initial = '" + textBox12.Text + '%' + "' OR Surname = '" + textBox12.Text + '%' + "' OR Initial = '" + textBox12.Text + '%' + "' OR [Post Town] LIKE '" + textBox12.Text + '%' + "' OR [Post Code] = '" + textBox12 + '%' + "')", conn);
            command.Parameters.Add(new OleDbParameter("@CustID" == Customer));
            OleDbDataReader Reader = command.ExecuteReader();

            LoopThroughRecs(Reader);

        }
        finally
        {
            conn.Close();
        }
    }

1 个答案:

答案 0 :(得分:0)

您可以使用相对较新的.postMessage()通过javascript在跨域网站之间进行通信。 Browser support is pretty decent with modern browsers

使用Google搜索可以找到很好的例子。 MDN文档是一个很好的起点。