Jump to content

How to create "speed bump" or capture an outbound link


jbutler

Recommended Posts

Can someone point me in the right direction?  I need to create a "speed bump" or one of those annoying messages that pops up when you click on an outbound link that says "Warning, you are about to leave this site, etc...).  I know I can do it with Javascript but would rather have a PHP capture the click and go to a page that says basically the same thing.

 

Any ideas?

U can use a php redirector script instead

 

if yer links were like: http://mysite.com/redir.php?url=xxxx

u wud have to use urlencode, to encode the original url.

 

THANKS!  This is what I want!  I don't know why they moved it to the Java forum when I specifically stated that.  Anyway, could you point me in the right direction and give more information?

 

THANKS! again!

Okay with some standard coding here, here is redir.php

this should work, as an example

<html>
<head>
<title>HTML Redirect Ad Example</title>
<?php
// Check for a url field, otherwise send to default page
$url=(!isset($_GET['url']))?'index.php':urldecode($_GET['url']);
// Javascript insertion detection
if(preg_match( "/([<>'\"]|&#039|!|&#34|%27|%22|%3E|%3C|&#x27|&#x22|&#x3E|&#x3C|\.js)/i", $url ))
  		$url='http://www.urbandictionary.com/define.php?term=twat';
  // Fix up any unprefixed urls
  if (substr($url, 0, 4) == "www.")
  	$url = "http://" . $url;

?>
<meta http-equiv="refresh" content="5;<?php echo $url; ?>">
</head>
<body>
<?php
$ads=array('google','yahoo','msn');
$show=rand(0,count($ads)-1);
?>
<h1>Ad for <span style='color: red'><?php echo $ads[$show]; ?></span></h1>
</body>
</html>

 

to use the code in yer site

  $redir="redir.php?url=".urlencode("http://www.google.com");

 

and that should do it :)

 

Note: Now if some moderator would be kind enough to move this thread back?

 

Good Luck

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.