iframe inside angular2 component, Property ‘contentWindow’ does not exist on type ‘HTMLElement’

The template doesn’t exist in the DOM yet when the constructor is executed Use instead import { Component, ViewChild, ElementRef } from ‘@angular/core’; @Component({ moduleId: module.id, selector: ‘component-iframe’, template: ‘<iframe #iframe></iframe>’ }) export class ComponentIframe { @ViewChild(‘iframe’) iframe: ElementRef; ngAfterViewInit() { let content=”<button id=”button” class=”button” >My button </button>”; let doc = this.iframe.nativeElement.contentDocument || this.iframe.nativeElement.contentWindow; doc.open(); … Read more

How to pass parameters through iframe from parent html?

On the main page simply pass parameters as follows function myFunction(){ $(‘#myIframe’).attr(‘src’, “myIframeRequest.html?param1=value1&param2=value2”); } In Iframe You can use a script to get the desired parameter value from parameters passed to page. <script> function getParamValue(paramName) { var url = window.location.search.substring(1); //get rid of “?” in querystring var qArray = url.split(‘&’); //get key-value pairs for (var … Read more

YouTube Autoplay does not work with iFrame

It’s not working since April of 2018 because Google decided to give greater control of playback to users. You just need to add &mute=1 to your URL. Autoplay Policy Changes <iframe id=”existing-iframe-example” width=”640″ height=”360″ src=”https://www.youtube.com/embed/-SFcIUEvNOQ?autoplay=1&mute=1&enablejsapi=1″ frameborder=”0″ style=”border: solid 4px #37474F” ></iframe> Update : Audio/Video Updates in Chrome 73 Google said : Now that Progressive Web … Read more

iframe refuses to display

It means that the http server at cw.na1.hgncloud.com send some http headers to tell web browsers like Chrome to allow iframe loading of that page (https://cw.na1.hgncloud.com/crossmatch/) only from a page hosted on the same domain (cw.na1.hgncloud.com) : Content-Security-Policy: frame-ancestors ‘self’ https://cw.na1.hgncloud.com X-Frame-Options: ALLOW-FROM https://cw.na1.hgncloud.com You should read that : https://developer.mozilla.org/en-US/docs/Web/Security/CSP https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy