Zend - The PHP Company




Miscellaneous

Add Code


. Add "Go Back" Frame to external links  

Type: application
Added by: fletcher
Entered: 11/03/2001
Last modified: 03/12/2000
Rating: **** (5 votes)
Views: 9832
Don't lose your website visitors when they link out of your website!! A short frame with "Back To My Site" and "Remove Frame" will be added to the top of any external URL link.


This script entails two files: redirect.php, and top.php.
Here's the code for redirect.php:

<?
# Redirect.php Copyright 2001 Jim Fletcher jim@WebsiteCode.com
#
# This script, when called, will look like:
# redirect.php?backtext=Back+To+My+World&backlink=http://www.myworld.com&linktitle=Microsoft+Website&url=http://www.microsoft.com
#
# All variables are optional, and you may set the default for left-out variables below.
#
if (!$sitetitle) {
    
$sitetitle="WebCustomerService.com";
}
if (!
$url) {
    
$url="http://www.websitecode.com";
}
if (!
$backtext) {
    
$backtext="Go Back To Site";
}
if (!
$backlink) {
    
$backlink=$HTTP_REFERER;
}
if (!
$linktitle) {
    
$linktitle="Redirection";
}
?>
<HTML>
<HEAD><TITLE><? echo $sitetitle?> Link To: <? echo $linktitle?></TITLE></HEAD>
<FRAMESET FRAMEBORDER=0 FRAMESPACING=0 BORDER=0 ROWS="40,*">
   <FRAME SRC="top.php?backtext=<? echo $backtext?>&backlink=<? echo $backlink?>&url=<? echo $url ?>" NAME="LinksFrame" MARGINWIDTH=0 MARGINHEIGHT=0 scrolling=no noresize BORDERCOLOR="#FFFFFF">
    <FRAME SRC="<? echo $url?>" NAME="AnswerFrame" BORDERCOLOR="#FFFFFF">
    <NOFRAMES>
        <BODY BGCOLOR="#FFFFFF">
        <p>Links Redirection works well only with frame-capable browsers.
        Please upgrade your browser to take advantage of this script.
        </p>
        <P>Click on the link to proceed to <A HREF="<? echo $url?>" TARGET="_top"><? echo $linktitle?></A>
        </BODY>
    </NOFRAMES>
</FRAMESET>
</HTML>



Here's The Code for top.php:

<html><head>
<SCRIPT Language="Javascript">
<!--
function RemoveFrames()
{
   parent.location.href = parent.LinksFrame.document.forms[0].elements[0].value;
   return false;
}

function OpenPopup(strFileName)
{
   popupWnd=window.open(strFileName,
      "PopupWindow",
      "toolbar=no,width=370,height=240,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
}
//-->
</SCRIPT>

</head>
<BODY BGCOLOR=#FFFFFF LINK=#000000>
<!--javascript:top.location = parent.document.referrer;"-->
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="2" BGCOLOR="#CCCC99"><TR ALIGN="CENTER"> 
<TD NOWRAP><FONT FACE="Verdana" SIZE="1"><B>� <b><a href="<? echo $backlink?>" target="_top"><? echo $backtext?></a> | <A HREF="<? echo $url?>" target="_top">Remove Frame</A></b>
</body>
</html>


Usage Example


If you set all the variables in the script, then you can just link to script as: redirect.php?url=http://www.wherever.com

However, if you want to specify any or all of the variables on a link by link basis, then a link might look like: redirect.php?sitetitle=My+World+Inc.&backtext=Back+To+The+My+World+Website&backlink=http://www.myworld.com&linktitle=Microsoft+Website&url=http://www.microsoft.com


Rate This Script





Search



This Category All Categories