Forum Moderators: open
the banner we're employing is a php file within an <IFRAME>. we can use php to get the header, but it only succeeds ~50% of the time (server side).
that's why i was wondering if there was a way to do this in javascript and pass the referer in to the php file so it can be logged.
does this make sense?
1) parent may be better than top - perhaps the calling page is itself in a frame.
2) There are security restrictions concerning cross-domain scripting, but I'm fairly sure that you can still read the location of the parent frame, even if it is in another domain - check this though.
Trouble is, you then need to find a way of sending this information back to your server
(all of these will require JS to be enabled, of course).
1) Load an image with the src as a script page, with a search string.
This method may be subject to privacy measures. There's no doubt a way that you can send the information in the requested filename itself (out of my league in server-scripting terms).
2) XMLHTTPRequest
Supported in more recent browsers.
3) Invisible Iframe
Probably the simplest, and least likely to cause complications - especially considering the simplicity of the task.
Include an invisible IFRAME in your own IFRAME. Then (after load) set the iframe's src to your serverscript page, sending the info in the request string.
with your help i think i've discovered a solution. i've tried:
1) getting the parent url via javascript (url of the site serving the ad)
2) pass it as a variable to my php banner ad (like banner.php?url=http://www.example.com)
3) then, log the url in my banner.php file
however, the url using parent.location.href isn't consistently being passed in. i guess this could be due to lack of javascript support on all browsers?
Having said that, if these inconsistencies are entirely due to client-side JS support, I would expect all banner-carrying sites to "report in" to some extent. That would make sense, wouldn't it? Do your results support that?
So, I must be doing something wrong... some of the ad networks that we're employing wrap our <IFRAME> banner within their own <IFRAME> to serve our ad.
However, top.location.href should always find the highest level URL, right?