Solved

Intermittent Page to Warn Visitors They Are Leaving Website?

Posted on 2012-04-03
5
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 110

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Survey branching tutorial 11 39
Jquery 7 32
What is define("__APPROOT__", __DIR__); 6 30
Find RGB colors from a screen. 2 17
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

756 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