admin管理员组

文章数量:1391929

Is there a way to determine in the child page's code behind that is was opened by the window.open() javascript mand from the parent page?

The pop-up page contains a user control that is used by other pages that are not spawned from a window.open() mand and I want to dynamically add functionality to close the page after the user has pleted their task in the child page.

It is an ASP.NET C# 3.5 application.

Is there a way to determine in the child page's code behind that is was opened by the window.open() javascript mand from the parent page?

The pop-up page contains a user control that is used by other pages that are not spawned from a window.open() mand and I want to dynamically add functionality to close the page after the user has pleted their task in the child page.

It is an ASP.NET C# 3.5 application.

Share Improve this question asked Dec 17, 2008 at 17:13 Michael KniskernMichael Kniskern 25.3k70 gold badges169 silver badges233 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 5

Can you pass through a flag in the querystring which will indicate where the window was spawned from?

in javascript you can check if window.opener is null

The request for the child window will probably have an HTTP Referer (referrer) header that points to the parent page. You could check that at the backend or check window.opener on client side.

Might be wrong, but I don't think there's a simple direct way to do this. You could always try to identify it from a distinct url, e.g. "MyChildForm.aspx?from=winopen"

--Edit-- Beaten to it by Galwegian

You could add some javascript in the usercontrol to test whether window.opener is non-null and on that basis hide or show the close page UI.

本文标签: cDetermine if aspx page was opened by a windowopen() commandStack Overflow