Hotlinking for Frames & Popup Window Problem Fix
The code in this package demonstrates two workarounds for a problem when
using Apache Server Software's .htaccess file to control file leeching - commonly called "hotlinking."
command with the URL value set to null, and (2) when using FRAMEs. Both of these situations can
cause Apache-based servers to deny otherwise valid requests for files. The issue is discussed in detail
below, which is also included in the package you can download using the button at the bottom of this page.
Working Around the .htaccess Referer Problem
in FRAMEs & Pop-up Windows
The original code is taken largely from a sample page at http://www.aerospaceweb.org/jeff/temp/test_popup.shtml which demonstrates a problem that people can run into when they use the Apache server control file .htaccess to prevent other websites from leeching image files, a practice known as "hotlinking," and thereby stealing both the artwork and the bandwidth from the host site.
The "onLoad" function will call the function writeMe from the parent window, which will fill in the dynamically generated content that we were after in the first place. I used the onLoad function because when I originally tried to update the window content within the function that opened it, the dynamic content was getting overwritten by the original content of the popup.html file. If there is a simpler workaround, I couldn't find it, so I resorted to the brute force approach of "onLoad". The onUnload function in popup.html will tell the parent window when you've closed the child. This prevents spawning multiple windows using the same windowObj variable which can lead to confusion if you try to use this code elsewhere. So now, if you click the "Show Photo" link in the parent page while the child window still exists, the child window is merely brought into focus and no new window is created.
The page at http://www.rainbodesign.com/pub/referer/frameset.html demonstrates this technique, in particular the page "main.html" which contains the IFRAME that displays the pumpkin.gif image. If you check the SRC parameter of the IFRAME in main.html, you'll see that it includes a query string as discussed above. This query string includes all of the information that the HTML shell page show_image.html needs to display the image. As long as the shell HTML document is stored on a valid referer host and the browser supports IFRAMEs, the Apache Server software will deliver the image file and the page will appear for the user as expected. This solution works for all known browsers released since January 2000, which covers just about everything out there now.
Referer.zip© is provided free of charge. If you use and appreciate it, please
post the following link in an appropriate location on your site:
a href="http://www.rainbodesign.com/pub/" Rainbo Design Tools & Scripts/a
This page was last modified on December 09, 2015