Addison111 0 Newbie Poster

I'm having a webpage that loads inside an iframe. I added the base tag to load the images, styling and to make links work, after clicking on a link I'm getting the error " refused to connect". Adding target="name-of-iframe" to all links doesn't work.


    <script type="text/javascript" src="jquery-3.2.1.min.js"></script>
            function getURL(url){
                document.getElementById('frame').src  = 'proxy.php?url='+encodeURIComponent(url);
        <button onclick="getURL( '')">Google</button>
        <iframe name="frame" id="frame" width="800" height="600" src=""></iframe>


    $page = get_page($_GET['url']);

    $page = str_replace("<head>","<head><base href=\"".$_GET['url']."\">",$page);

    echo str_replace("<a","<a target=\"frame\"",$page);

    function get_page($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);

        $proxy = '';
        curl_setopt($ch, CURLOPT_PROXY, $proxy);

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $data = curl_exec($ch);
        return $data;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.