Connecting Tech Pros Worldwide Forums | Help | Site Map

Problems with Firefox and Calling a Remote Script

bbammes@gmail.com
Guest
 
Posts: n/a
#1: Mar 8 '07
I'm writing a click tracking program which calls a remote PHP script
when a user clicks a link. My javascript is:

<script type="text/javascript">
//<![CDATA[
function trackclick( id ) {
if( document.images ) {
( new Image( ) ).src = "http://www.example.com/scripts/
trackclick.php?" + "id=" + id + "&referrer=" +
escape( document.referrer ) + "&clientagent=<?php echo
urlencode( $_SERVER[ 'HTTP_USER_AGENT' ] ); ?>&clientaddress=<?php
echo urlencode( $_SERVER[ 'REMOTE_ADDR' ] ); ?>";
}
return true;
}
//]]>
</script>

This function is called from the onclick events of links throughout
the page.

This works flawlessly in IE, but I can't get it working in Firefox.
I've spent awhile debugging this... Firefox executes trackclick( ) on
an onclick event... "document.images" evaluates as true in Firefox...
so the problem seems to be that Firefox never calls my PHP script
(i.e. it never tries to get the new image data).

Anyone have any ideas? Thanks!


bbammes@gmail.com
Guest
 
Posts: n/a
#2: Mar 8 '07

re: Problems with Firefox and Calling a Remote Script


I got my code working... it seems that Firefox's security won't let
you execute a remote script (it seems to only allow execution local
PHP scripts). So I created a local PHP script that opened an HTTP
socket to the remote script. This got everything working properly.

Closed Thread