当我在我的HTTP
页面中嵌入外部HTTPS
iframe时,收到混合内容错误消息:
<iframe src="http://www.example.com/"></iframe>
要解决此限制,我想从我自己的域中回显外部页面。我该怎么做?
谢谢!
答案 0 :(得分:1)
使用http
(或任何其他lib)调用curl
页面,并将响应打印到某些div
(此div
将代替{{ 1}})。
如果您想要更多指示,请附上您的iframe
页面(包含PHP
的人)...
proxy.php
iframe
page.html中
<?php
$url = "http://url-of-iframe/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$response = print curl_exec($ch);
//in case that the page does not contains the <base> tag, then add it
$base = '<base href="http://www.base-of-iframe.com/" /><!--[if IE]></base><![endif]-->';
$response = str_replace("<head>", "<head>".$base, $response);
?>
您必须确保 <html><iframe src="https://www.yourServer.com/proxy.php"></iframe></html>
是受信任的网站!否则,他可以将恶意内容加载到您的页面中!