I'm building a small tracking script for some of my domains and want to load a php script from another domain. I just need to gather the ip address of the visitor on domain A and pass it to another script on domain B. There is no way to get the ip address with pure javascript so I thought I go for a mix of php and javascript which seems to work like in this case. http://www.hashemian.com/tools/visitor-IP.htm <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> Code (markup): He uses this snippet to embed a fake javascript file and then uses probably $_SERVER['RemoteADDR'] to get the ip and parses it back to the site. My problem is that I can't get parse any output on domain A that has the script from domain B embedded. I tried to echo the results or document.write but nothing worked. It is displayed if I view the file on domain B but not if I embed it on domain A. Any help would be great. If you have other suggestions how I could gather the ip on domain A and pass it on to the script on domain B would be cool too.
How about something like this. On Domain A (http://testDomainA.com) make your ip fetching script, we'll call it get_ip.php: function getRemoteIp() { var toReturn='<?= getenv('REMOTE_ADDR') ?>'; return toReturn; } Code (markup): And on Domain B you can call the getRemoteIp() javascript function.. like for example to fill in a form element or something: <html> <script language="JavaScript" src="http://testDomainA.com/get_ip.php"></script> <script language=JavaScript> function showIp() { var foundIp=getRemoteIp(); document.getElementById('ipField').value=foundIp; } </script> <body onLoad='showIp();'> This is a test.<p> Your Ip is: <input type=text size=25 value='' id='ipField'> </body> </html> Code (markup):