/    Sign up×
Community /Pin to ProfileBookmark

Opening iframe link in the same iframe not working

I have 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 “whatsmyip.com refused to connect”. Adding target=”name-of-iframe” to all links doesn’t work.

HTML

<html>
<head>
<script type=”text/javascript” src=”jquery-3.2.1.min.js”></script>
<script>
function getURL(url){
document.getElementById(‘frame’).src = ‘proxy.php?url=’+encodeURIComponent(url);
}
</script>
</head>
<body>
<button onclick=”getURL( ‘https://whatsmyip.com/’)”>Google</button>
<iframe name=”frame” id=”frame” width=”800″ height=”600″ src=””></iframe>
</body>
</html>

PHP

$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 = ‘14.207.72.213:8080’;
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);
curl_close($ch);
return $data;
}


to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJan 21.2019 — Quick look tells me you have an extra / in your button's onclick clause.
×

Success!

Help @freeman11777 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...