【发布时间】:2015-11-13 00:55:49
【问题描述】:
在我的项目中,我有一个主页,用户登录并查看主表,以及许多在不同窗口中打开的附加页面。
当登录超时时,用户应该不能访问任何内容。在主页中,我再次给出了登录页面的链接。在子窗口中,我不能这样做,因为我不希望在子窗口中完成登录。
在javascript中,我可以使用window.opener来访问主窗口(因为每个子窗口都是用window.open打开的)。如何在 html a 标记中做到这一点?
if (!login_check($conn)) { // tests if the user is connected
// exits with a message, if not connected anymore
exit("<p>You don't have authorization to access this page. Please, <a href='index.php' target='_parent'>go back to main screen and login</a>.</p>");
}
问题是:这段代码在子窗口中打开了登录页面,所以target='_parent' 不像我想象的那样行事。如果有的话,实现这一目标的正确方法是什么?
【问题讨论】:
标签: javascript html href window.opener