您是否尝试过 window.opener.location.href(在 javascript 中)?
您还可以使用开启器在 javascript 中调用 pageMethod,以从您的(服务器端查询)中取回您的 CSS 并将其应用到您的 javascript 页面中。
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
使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.UI;
使用 System.Web.UI.WebControls;
使用 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>