当前位置:网站首页>Page embedded iframe click browser back problem
Page embedded iframe click browser back problem
2022-06-23 07:04:00 【SeriousLose】
Page embed iframe Click the browser to go back
- stay iframe binding load event , In this way, you can listen to the open iframe Click browser back Button event ;
<div [hidden]="!iframePageDisplay" class="iframeStyle">
<iframe [src]="iframeUrl" width="100%" height="100%" frameborder="0" id="message" name="nameOfThematicProgrammes" (load)='iframeOnload()'></iframe>
</div>
- load Incident , open iframe,push Go in one history;
iframeOnload(){
if(this.iframePageDisplay){
let state = {
title: "title",
url: window.location.href,
};
window.history.pushState(state, "title", state.url);
}
}
- Add browser listening events
popstateHandler: any;
this.popstateHandler = this.backPopstate.bind(_this);
window.addEventListener('popstate', this.popstateHandler,true)
// Browser return execution method
backPopstate(){
if(this.iframePageDisplay){
this.iframePageDisplay = false;
history.back();
window.removeEventListener('popstate', this.popstateHandler, true);
}
}
- Remove the added browser event ;
ngOnDestroy(){
window.removeEventListener('popstate', this.popstateHandler, true);
}
边栏推荐
猜你喜欢
随机推荐
网页制作存在的一些难点
[project training] multi segment line expanded to parallel line
Some difficulties in making web pages
[STL] summary of stack and queue usage of container adapter
[project training 10] drawing of arrows
xml schem 记录
QT method of compiling projects using multithreading
js数组的索引为何不能用负数
反鸡汤致辞
Endnote20 tutorial sharing (unfinished
[STL] summary of deque usage of sequential containers
MySQL Redo log Redo log
Chrome删除重复书签
MySQL mvcc multi version concurrency control
C # how to obtain DPI and real resolution (can solve the problem that has been 96)
/Bin/sh no such file or directory problem
TP6 安装拓展
开源OAuth2框架 实现SSO单点登录
Mongodb record
产品-Axure9(英文版),原型设计 制作下拉二级菜单

![[STL] summary of pair usage](/img/ba/72697f0f8bf018f1b5884e9cc2be4e.png)


![[project training] change of linear arrow](/img/a4/7554522c13684d7590d247f28a6965.png)



