Forum Moderators: open
I am putting together a set of pages that will be displayed through iframe, but if they are not I need to add additional content. Is there a way to detect this or should I just pass a variable along with the call to the page in the iframe code?
I have a page on a site that I'm designing to be used in an iframe for my members to display through their sites. But they can also send people to my site directly to view the same page with a login in case they don't have their own site or don't know how to use HTML.
If they choose to send their customers to my site to view the page I want to display Adsense code, but if the page is shown in a frame I don't want the ads to appear.
The code you gave me works great in determining if the content I want to display should or should not be displayed, but the Adsense code loads a script using a "src=" method and I'm not sure how to add the adsense code within an IF statement.
Has anyone done this before?
if (top!=self) top.location.replace(location.href); If the adsense code is stored on your server, you can modify it directly, however, if external to your site, you can use document.write() to insert the <script> tag necessary to load the adsense code.
Kaled.
I want to display the ads to their customers but only if they send their customers to my site to view their page. (It's a cart system that I'm redesigning)
Besides I believe that displaying Adsense on another site is against the TOS, which is what I'm trying to prevent.
I'm trying to use cookies to determine weather the page is framed earlier on, and then check the cookie to determine if the Adsense code should be displayed. So far so good, but setting cookies with a framed page is not that easy. I'm having trouble with the whole privacy policy thing.
I was hoping there was a way to pass a variable from Javascript directly to PHP in the same page, but I think cookies are the only way to do it.
Try the following, its a little simpler than the version above.
<script type="text/javascript">
if (top==self) document.write('<script type="text/javascript" src="googleurl"><\/script>');
</script> Kaled.