最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Determine if aspx page was opened by a window.open() command - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论