我想打开一个报告页面,以便从登录页面进入主页面,该页面本身将在新窗口中打开。在主页面上,有两个按钮。单击任何按钮,它将在新窗口中打开与该按钮关联的特定报告。
现在,问题是每个报告页面上都有一个链接应该返回到主页面(即它应该最小化报告页面)。此外,如果用户再次打开第二个报告,它将在新窗口中打开并点击主页面链接,它还应该最小化第二个报告窗口。
此外,还有3页的注销,即主页,第一报告和第二报告。因此,如果有的话,单击主页面上的Logout应关闭所有最小化窗口。单击任何其他页面的注销,即其他报告,它应该使会话无效。
我的问题是,从第一次调用Logout时,我无法关闭第二个子窗口。此外,如果从主页面调用logout,如何关闭所有弹出窗口。
我用来打开登录主页面的代码 -
export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
constructor(private heroService: HeroService) { }
ngOnInit(): void {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));
}
gotoDetail(hero: Hero): void { /* not implemented yet */}
}
从主页打开报告的代码 -
function RedirectPage(path)
{
var intWidth = screen.width - 10; //Adjust for the end of screen
var intHeight = screen.height - 80; //Adjust for the Icon Bar at the bottom of the window.
var strWinProp = " toolbar=no" //Back, Forward, etc...
+ ",location=no" //URL field
+ ",directories=no" //"What's New", etc...
+ ",status=yes" //Status Bar at bottom of window.
+ ",menubar=no" //Menubar at top of window.
+ ",resizable=yes" //Allow resizing by dragging.
+ ",scrollbars=yes" //Displays scrollbars is document is larger than window.
+ ",titlebar=yes" //Enable/Disable titlebar resize capability.
+ ",width="+intWidth //Standard 640,800/788, 800/788
+ ",height="+intHeight //Standard 480,600/541, 600/566
+ ",top=0" //Offset of windows top edge from screen.
+ ",left=0" //Offset of windows left edge from screen.
+ "";
var win = window.open(path,'_blank',strWinProp);
self.setTimeout("closeMe()",500);
}
我用来打开报告2的相同代码只是我使用不同的网址。
点击从子项退出时我正在调用此函数 -
function report1() {
sessionId = getURLParameters('requestID');
userName = getURLParameters('userName');
userId = getURLParameters('userId');
lvalue = getURLParameters('lValue');
lver = getURLParameters('lVer');
window.name = "parent";
var intWidth = screen.width - 10; //Adjust for the end of screen
var intHeight = screen.height - 80; //Adjust for the Icon Bar at the bottom of the window.
var strWinProp = " toolbar=no" //Back, Forward, etc...
+ ",location=no" //URL field
+ ",directories=no" //"What's New", etc...
+ ",status=yes" //Status Bar at bottom of window.
+ ",menubar=no" //Menubar at top of window.
+ ",resizable=yes" //Allow resizing by dragging.
+ ",scrollbars=yes" //Displays scrollbars is document is larger than window.
+ ",titlebar=yes" //Enable/Disable titlebar resize capability.
+ ",width="+intWidth //Standard 640,800/788, 800/788
+ ",height="+intHeight //Standard 480,600/541, 600/566
+ ",top=0" //Offset of windows top edge from screen.
+ ",left=0" //Offset of windows left edge from screen.
+ "";
window.open(Url + userName + "&requestID=" + sessionId + "&userId="
+ userId + "&lValue=" + lvalue + "&lVer=" + lver,'_blank',strWinProp);
}
使用相同的退出功能第二个孩子
主页的退出功能 -
function logout()
{
opener.location.href = '/Login.html';
close();
}
答案 0 :(得分:0)
打开窗口时:
var win = window.open(path,'_blank',strWinProp);
该窗口可以通过以下方式访问他的开场白:
window.opener
然后,在每个子窗口中,您可以使用自己的window
对象控制其行为,并使用window.opener
调用父方法或属性。