I'm trying to add a booking.com embedded widget to project. On the first request for the main page it works fine, you can see the map and booking widget for ordering. However, when you switch the view (not leaving the page or closing tab) and pressing back to return to the main page, it becomes a link and the embedded map widget is not presenting. Upon loading the main page I can see requests for booking and it returns a JS script. After this script a lot of scripts/html like google maps been called, but it is only happening only on main page and once, other times a still see script been called, but nothing else don’t.
import { Component, Inject, OnInit, Renderer2 } from '@angular/core';
import { DOCUMENT } from '@angular/common';
@Component({
selector: 'jhi-booking-frame',
templateUrl: './booking-frame.component.html',
styles: []
})
export class BookingFrameComponent implements OnInit {
name = 'Angular';
constructor(private _renderer2: Renderer2, @Inject(DOCUMENT) private _document: Document) {}
ngOnInit(): void {
const s = this._renderer2.createElement('script');
s.type = 'text/javascript';
s.async = false;
s.src = '//aff.bstatic.com/static/affiliate_base/js/flexiproduct.js' + '?v=' + +new Date();
const elementsByTagNameElement = this._document.getElementsByTagName('head')[0];
this._renderer2.appendChild(elementsByTagNameElement.parentElement, s);
}
}
<ins class="bookingaff" data-aid="0000" data-target_aid="0000" data-prod="map" data-width="100%" data-height="590" data-lang="ualng" data-dest_id="0" data-dest_type="landmark" data-latitude="35.6894875" data-longitude="139.6917064" data-mwhsb="0" data-checkin="2019-05-20" data-checkout="2019-05-21">
<!-- Anything inside will go away once widget is loaded. -->
<a href="//www.booking.com?aid=0000">Booking.com</a>
</ins>
I already tried hooks of angular like afterInitView,onInit,etc.
It should stay like in this example https://stackblitz.com/edit/angular-8564pe?file=src%2Fapp%2Fapp.component.html but insted its only show a link to booking.