I have a site with several DHTML applets that launch in their own custom-sized pop-up-style windows, nominally launched via a small Javascript script. Here is a typical launch hyperlink:
Code: Select all
<a href="javascript:popup_display('http://www.foo.com/applet1/index.php',800,700);">I however have many web visitors who try to access the applets directly by bookmarking or typing in the URL of the applet directly into the address bar of their browser. The applets work Ok when they do that, but the display format is wrong because they are not getting the custom-sized popup window, but rather getting the applet displaying right in the parent window.
I have tried alleviating that problem by testing for the calling host to make sure that they are getting there via a link from within my website and not calling the applet page directly themselves. I have done this using the follwing PHP at the beginning of each applet:
Code: Select all
<?php
$refering_page = $_SERVER['HTTP_HOST'];
if ( ! strstr($refering_page, "foo")) {
header("Location: http://www.foo.com/appletmenu.php");
}
?>
This works fine in a Firefox browser, but in IE (back to at least 6) it doesn't work, because IE apparently does not set 'HTTP_HOST' when the call is made from a javascript function.
Does anybody know of a way in which I can ensure these applets are being launched from my own menu page and not from an outside referal that works in both browsers?
Thanks in advance for any assistance,
G.