I'm using Angular (not important for this problem but explains the syntax) and have something like this:
HTML:
<button (click)="setIframeSrc('http://mypage.com/page1')">Page 1</button>
<button (click)="setIframeSrc('http://mypage.com/page2')">Page 2</button>
<iframe [src]="iframeSource"></iframe>
Typescript:
setIframeSrc(url) {
this.iframeSource = url;
}
The site "mypage.com" is my own website that is a SPA application, meaning there is no page reloads happening when going from Page 1 to Page 2.
Current behaviour
- I click the "Page 1" button
- The iframe loads in
mypage.com/page1
- I click the "Page 2" button
- The iframe reloads and loads in
mypage.com/page2
Wanted behaviour:
- I click the "Page 1" button
- The iframe loads in
mypage.com/page1
- I click the "Page 2" button
- A navigation to
mypage.com/page2
occurs in the iframe without reloading the whole iframe
When I click the two buttons I want "mypage.com" to only load on the first click and every subsequent click should not reload the iframe but just navigate inside the iframe.