View Single Post
Old 10-22-2009, 02:12 PM   #1 (permalink)
n1colius
The Visitor
 
Join Date: Oct 2009
Posts: 4
Thanks: 2
n1colius is on a distinguished road
Default [ASK] get parent url in iframe

I have a proble in getting parent url address in iframe from my project.

so, i have let's say ads.php located in www.domain1.com/ads.php
it's look like this
Code:
<?php
//iklan.php
if($_GET['klik'] == 'yes')
{
    //klik process
    exit;
}

$some_content = '
	document.write('<iframe src="www.domain1.com/ads.php">
	<a href="www.domain1.com/ads.php&klik=yes">klik_link</a>
	</iframe>');
	';
echo $some_content;
?>
and then i have test.html located in www.domain2.com/test.html that look like this
Code:
<html>
<head>
</head>
<body>
<script type="text/javascript" src="www.domain1.com/ads.php">
</script>
</body>
</html>
my question is, how can i get the value of url address frame parent which is "www.domain2.com/test.html" in my ads.php file.

i already try $_SERVER['HTTP_REFERER'] and $_SERVER['SERVER_NAME'] but i got me "www.domain1.com/ads.php" which is the src of my iframe.

i also try with javascript "parent.location.href" but failed, because it's only work if the domain is the same.

anyone has a solution? been struggling with this in this 2 day.
Send a message via Yahoo to n1colius
n1colius is offline  
Reply With Quote