I have two CDN domains, one that delivers content over https and the other one through http. And I’m creating a widget (inside an iframe) that could be used in a variety of domains and sometimes in secure pages and sometimes not.
Is there a way to infer using JavaScript the parent’s protocol from within the widget’s iFrame ?
I have two CDN domains, one that delivers content over https and the other
Share
I figured it out, if I ommit the protocol in the iframe of my widget then it will inherit the protocol of the parent, eg:
In my widget html:
The iframe code that points to my widget (to insert into the other sites):
This requires my-wdiget.example.com/widget to work for both secure and unsecure connections (ie: http://my-widget.example.com/widget and https://my-widget.example.com/widget should both point to the same content) but that’s OK because in my situation the only domains I don’t have control over are the ones used as CDN.