magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2001 > 05 > Help Desk  

Help Desk

By Ken Cox, guest Webmaster

Bandwidth Hogs

How can I use JavaScript to stop file leeches who link directly to a graphic on my site and use up my bandwidth? I haven't discovered any tricks to keep the browser from revealing the URL, although I have stopped it from appearing on the status bar of the source by using a JavaScript function to build the URL of the graphics. The graphics are viewed in a separate window, so it's difficult to allow that, yet stop direct linking from guest books and the like. Any ideas?
—Louis

A server-side script would certainly help in this situation because it would let you store the images in a database. In doing so, you would have total control over the name of the file. You could even create a random filename for each image that only your script and database would recognize.

However, your question involves using JavaScript on the client. The problem with your situation is that as long as your own Web pages can find the files, other Web pages can do the same. If you want to make the files harder for other sites to decipher, you could try something like the following, which programmatically assigns the filename in a slightly convoluted format:

<html>
<body>
<img id="mypic" name="mypic" src="http://www.newarchitectmag.com/documents/s=4450/new1013636393/"></p>
<script language="javascript">
document.images[0].src="http://www.newarchitectmag.com/documents/s=4450/new1013636393/my" + "pic.gif";
document.images[0].width="114";
document.images[0].height="110";
</script>
</body>
</html>

Using a tool like Macromedia Fireworks 4 to slice a single image into several pieces is another approach to disguising your images.




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2