|
||
| Inside Technique : Tell a Friend This article was inspired by the "Tell a Friend" feature at the WebReference.com web-site (another great web developer site). WebReference.com uses a Perl Script to implement this feature. Since we use ASP on SiteExperts.com, we set out to create a similar feature using VBScript. The "Tell a Friend" feature makes it easy to send an e-mail to a friend recommending an article on a site. "Tell a Friend" works through special links on your web-page. When this link is clicked on, you are taken to a web-page where you can recommend the page to a friend or co-worker. The simplest approach is to embed the URL of the recommended page directly in the "Tell a Friend" link. The link would be specified as follows: <A HREF="recommend.asp?p=/yourpage.htm">Tell a Friend</A> A similar approach is to just look at the referring page. This usually returns the page that linked to the Tell a Friend page. We don't like this approach as it is not very reliable. Many times the referrer is not sent along. Instead, to help automate the generation of the link, we came up with a simple client-side javascript. You just include this client-side javascript on pages you want to support "Tell a Friend" and make sure you point to the "Tell a Friend" page and you are all set!
<SCRIPT>
document.write("<A HREF=\"recmail.asp?p=" +
escape(window.location.pathname) + "\">Tell a Friend</A>")
</SCRIPT>
This approach allows you to supply any URL as the destination for the recommendation. This was an approach we first planned to take. This approach has a potential problem - any user can call your page with any other page on the internet. For example, you probably don't want mail sent from your site recommending competitor sites or possibly illicit sites. This can be remedied by specifying all your links as absolute URL's and verifying the passed in file exists on your server. This is easily accomplished on the server with the FileSystem object.
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(server.mappath(src_page)) Then
// Exists
end if
We are now ready to show you how to build the complete "Tell a Friend" ASP page. On the next page we show you the steps for setting up and writing the complete script. Page 1:Tell a Friend © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |