duanbiaojin8860 2015-11-25 13:25
浏览 58

如何将外部网站加载到我自己的网站?

I have tried using iframes, but it has not worked because of the same-origin error.

<div align="center">
<iframe src="http://sms.webzworld.com/" style="overflow:hidden"></iframe>
</div>

I tried a little bit of ajax but I was unsuccessful; I have very little knowledge of Ajax and jQuery, so I did not go too deep into this topic. That said, if there is a solution using Ajax and jQuery then I don't mind looking into it.

Now i am having a look at curl library in php to solve my problem. It doesnt load the external website but in a very hap hazard way.The code i use is as follows:

<?php
function Get_Domain_Contents($url){
        $ch = curl_init();
        $timeout = 5;
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;   
}

$url = 'http://sms.webzworld.com/';

$html = Get_Domain_Contents($url);

$html = "<base href='{$url}' />" . $html;

?>

<div src=""><?php echo $html; ?></div>

This is how my site looks

In the plain white section is where i want the external website to load. But after i use the curl code mentioned above i get this output.

Output after the curl code used

As you can see that the external website overlaps my own website.

So can anybody help me out with an effective solution?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 github训练的模型参数无法下载
    • ¥15 51单片机显示器问题
    • ¥20 关于#qt#的问题:Qt代码的移植问题
    • ¥50 求图像处理的matlab方案
    • ¥50 winform中使用edge的Kiosk模式
    • ¥15 关于#python#的问题:功能监听网页
    • ¥15 怎么让wx群机器人发送音乐
    • ¥15 fesafe材料库问题
    • ¥35 beats蓝牙耳机怎么查看日志
    • ¥15 Fluent齿轮搅油