Reputation: 5085
Would it be possible if a user clicked on a link inside an iframe showing an outside site to have the webpage request be routed through the server that the iframe is hosted on?
Example: Iframe on somesite.com showing google.com User clicks a result link to someothersite.com The request is sent through somesite.com's server and is logged so that they now have a record of what link they clicked on.
Possible? Not?
Thanks.
Upvotes: 0
Views: 261
Reputation: 321796
No, the browser's security model should prevent you from tampering with a website on a different domain (which you would have to do to intercept the clicks).
You could proxy the iframe through your own server and re-write it...
<iframe src="proxy.php?src=www.google.com"></iframe>
The basic idea of proxy.php would look something like (this is not supposed to be finished or even working - just to give you the idea of how it should work):
<?php
// Get the contents
$html = file_get_contents($_GET['src']);
// Rewrite the links
$html = preg_replace('/href=["\']?/i', 'href=clicky.php?src=', $html);
// Output the HTML
print($html);
?>
Upvotes: 1