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?

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.