gdfgdfg
gdfgdfg

Reputation: 3566

Add iframe with jQuery from HTTP to HTTPS

Hi I have page which is under HTTPS, because I can manipulate only JS and CSS on it, I created free host HTTP and upload content there. After that I added with jQuery, iframe element to the HTTPS page with src to the HTTP page, but I see this error in the console:

Mixed Content: The page at 'https://url.bg/' was loaded over HTTPS, but requested an insecure resource 'http://url.000webhostapp.com/'. This request has been blocked; the content must be served over HTTPS.

This is for Chrome and this for Mozilla: Blocked loading mixed active content “http://url.000webhostapp.com/”

Is there any solution for that ?

My JS code is simple:

$('body').children().remove();
$('body').append('<iframe src="http://inovativa.000webhostapp.com/"></iframe>');

Upvotes: 0

Views: 660

Answers (1)

karthick
karthick

Reputation: 12176

Why don you write url agnostic code?

https page needs to load https resources. If the external link has support for https then load the url using '//', which means when you page is in http load the resource using http protocol. if in https then https.

$('body').append('<iframe src="//inovativa.000webhostapp.com/"></iframe>');

Upvotes: 1

Related Questions