简体   繁体   English

如何从radwindow中检索“父母”页面的名称?

[英]How to retrieve the name of the “Parent” page from the radwindow?

I found a small problem with my asp website. 我在我的asp网站上发现了一个小问题。 Here is the principle. 这是原理。 -> I set a popup window to allow a user sends an email alert bug. ->我设置了一个弹出窗口,以允许用户发送电子邮件警报错误。 And when the email is sent, I would send the name of the current page of the user. 当发送电子邮件时,我将发送用户当前页面的名称。 However this returns me the name of the popup window and not the parent page .... 但是,这将返回弹出窗口的名称,而不是父页面的名称。

How to retrieve the name page ('.aspx') of the "Parent" page from the radwindow (popup) ? 如何从radwindow(弹出窗口)中检索“父”页面的名称页(“ .aspx”)?

i have try this but it's not working 我已经尝试过了,但是没有用

From within the popup window's hosted HTML you can access the hosting page's DOM with a snippet of Javascript such as the following: 在弹出窗口的托管HTML中,您可以使用Javascript片段访问托管页面的DOM,例如:

  <script>
     alert(window.top.document.title);
  </script>

This will return to you a nice alert box with the title of the page hosting the RadWindow. 这将返回一个不错的警告框,其中包含托管RadWindow的页面的标题。

Can you try that : 你可以试试看吗:

//myWindow beeing the popup 
myWindow.document.write("<br><br>" + myWindow.opener.document.location.href + "")

Update 更新资料

If you cannot get the popup window object you can pass the url of the calling window in the query string : 如果无法获取弹出窗口对象,则可以在查询字符串中传递调用窗口的URL:

radopen('urlOfThePopup.aspx?opener=' + document.location.href, ...)

Then in your popup code 然后在您的弹出代码中

<%=Request.Querystring("opener")%> 

Assuming you have a RadWindow and not an actual browser popup, this is the code you'll need: 假设您有一个RadWindow而不是实际的浏览器弹出窗口,这是您需要的代码:

// This is a common function when dealing with RadWindows and could be placed in some shared location
function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

// Use it like this
var parentTitle = GetRadWindow().BrowserWindow.document.title;

What exactly are you trying to get? 您到底想得到什么? A page has a title, not a name. 页面具有标题,而不是名称。 Anyway, take a look at this: http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html . 无论如何,请看一下: http : //www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html It will show you how to call a JavaScript function on the main page so it can return whatever JS object you need. 它将向您展示如何在主页上调用JavaScript函数,以便它可以返回所需的任何JS对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM