Solved

Intermittent Page to Warn Visitors They Are Leaving Website?

Posted on 2012-04-03
5
323 Views
Last Modified: 2012-04-18
I want to warn visitors they are leaving my (Drupal) website when they click on certain links (that lead to other external sites).

Is there a module for this? Or what other approach?
0
Comment
Question by:sandshakimi
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
junipllc earned 250 total points
ID: 37801759
there is a module for 6 but I'm not sure if it has been ported to 7. I'm not at an actual desktop machine but when I get to one i will check for it. there is also a very simple jquery solution you can use.

either way it's easy to do. I should be off of this awful phone interface and be able to check in a bit for you.

mike
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 37801918
I have done this in the past by using a separate "goodbye" page in place of the conventional anchor tag.  You pass it a URL argument of the destination page.  If the destination is off the site, it loads a message telling the client that they are exiting the site.  I believe you can also do this with JavaScript.  You might be able to adapt this function to meet your needs.
<?php // RAY_leaving_the_site.php
error_reporting(E_ALL);

function ELink($url, $text=NULL, $class=NULL, $target=NULL)
{
    // IF NO TEXT, USE THE URL
    if (!$text) $text = $url;

    // PREPARE THE LINK TEXT
    $link = '<a';
    if ($class)  $link .= ' class="'  . $class  . '"';
    if ($target) $link .= ' target="' . $target . '"';
    $link .= ' href="' . $url . '">';
    $link .= $text;
    $link .= '</a>';

    // IF THIS IS AN EXPLICIT LINK
    $rgx
    = '#'          // REGEX DELIMITER
    . '^'          // STARTS WITH
    . 'http'       // EXPLICIT URL
    . '#'          // REGEX DELIMITER
    . 'i'          // CASE-INSENSITIVE
    ;
    if (preg_match($rgx, $url))
    {
        return "CLICK HERE TO LEAVE THIS SITE: $link";
    }
    // IF THIS IS A RELATIVE LINK
    else
    {
        return $link;
    }
}

// USE THE FUNCTION
echo PHP_EOL . '<br/>' . elink('http://www.google.com');
echo PHP_EOL . '<br/>' . elink('http://www.google.com', 'Google', 'offsite', '_blank');
echo PHP_EOL . '<br/>' . elink('index.php', 'Home Page');

Open in new window

0
 
LVL 12

Expert Comment

by:junipllc
ID: 37808775
If you don't actually need the intermediary page but instead just a warning, then this is the module I was talking about, and it works in D6 and D7:

http://drupal.org/project/extlink

Mike
0
 

Author Comment

by:sandshakimi
ID: 37850825
Ray, is this the intermediate page that visitors will be directed to before leaving the site?
0
 

Author Closing Comment

by:sandshakimi
ID: 37861348
To makes simpler, I decided to use a static php page. Thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now