We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18908
    • 11 Posts
    I am using ModX Evolution and love it! I am working on a site for a bank, and all external links need to be coded with something that pops and says your are leaving the website, do you want to continue...

    Any ideas?
      • 29181
      • 480 Posts
      I think you should use a little javascript tied to all links. You could simply tie it to all <a> tags (I like jQuery) with a function along these lines

      Semi pseudo code

      if($(this).attr(’href’).indexOf("yourdomain.com")<0))
      {
      alert("Please don’t leave :-(")
      }

      Hth
      Taff
        Adrian Lawley: www.adrianlawley.com
        • 33968
        • 863 Posts
        Typical banks!

        I was thinking javascript too - this one looked alright - but you should probably let your client know that it won’t work if the visitor has js disabled. How rigid they would be about that I don’t know. But I’m not sure how you could do it without javascript undecided
          • 33997
          • 150 Posts
          I don’t know how they do it, but deviantart.com has this type of thing. If you click on an outgoing link it takes you to an in-between page - see here: http://www.deviantart.com/users/outgoing?www.maximumhandyman.com
            "Great spirits have always encountered violent opposition from mediocre minds." -Albert Einstein
            • 33968
            • 863 Posts
            Ah that’s a good idea - a bit more friendly than an alert box and will work even without js.

            You could do that with a plugin that checks whether the link is external or not, and if so, passes the link to a snippet on the ’in between’ page. On that deviantart site they’ve passed the link to the intermediate page via url parameter:
            outgoing?www.maximumhandyman.com
              • 33968
              • 863 Posts
              Did you get anywhere with this? I have a plugin+snippet combination working if you still need it... works the same as deviantart.com
                • 18908
                • 11 Posts
                Quote from: lucas at May 09, 2011, 10:45 AM

                Did you get anywhere with this? I have a plugin+snippet combination working if you still need it... works the same as deviantart.com

                I would be interested in your solution, I haven’t started working on this yet.

                  • 18908
                  • 11 Posts
                  Quote from: lucas at May 06, 2011, 07:40 AM

                  Typical banks!

                  Unfortunately, it is an FDIC guideline:

                  Per the Interagency guidance “Web-linking: Identifying Risks and Risk Management Techniques” issued April 23, 2003, the customer must be given the opportunity to accept or decline leaving the bank’s website.

                  Quote from: lucas at May 06, 2011, 07:40 AM
                  I was thinking javascript too - this one looked alright - but you should probably let your client know that it won’t work if the visitor has js disabled. How rigid they would be about that I don’t know. But I’m not sure how you could do it without javascript undecided

                  I saw that one but wasn’t sure what to do with this line, if anything:
                  if(Drupal.jsEnabled) {


                  And, do I just drop this code in everywhere I have an external link?

                  Sorry, I’m not much of a coder (just enough to be dangerous).
                    • 33968
                    • 863 Posts
                    I guess the author intended it for Drupal, you could remove that line (along with the closing brace ’}’ at the end of the script).

                    My solution will work even if the user has js disabled, which I guess is preferable given the rigid guidelines you’re working with. I’m in the middle of something now but will try to post it for you later today or tomorrow...
                      • 33968
                      • 863 Posts
                      Sorry, have been a bit busy the last few days. Never a bad thing smiley

                      I'd set this up for Revo but converted it over to Evo for you. Both versions are attached. Basically, the plugin fires when a page is being loaded. It finds all links on the page and checks to see if they are external or not; if external, it is replaced with a link to your 'disclaimer' page. The snippet will be on the disclaimer page waiting to catch and display the external link, with another link back to the previous page.

                      Please note that if the external link does not begin with a valid url scheme such as 'http', 'https', 'ftp', 'file', or 'mailto' it will not be recognised as an external link and the user will end up on your 404 page. See below if you need to add more schemes.


                      Setup instructions:

                      snippet.exthref.php
                      Create a new snippet called 'extHref' and paste the contents of the file provided.

                      Create a new document for your 'disclaimer' page. Paste in the following snippet call where you want your links to appear:
                      [!extHref? &tpl=`linksTpl`!]
                      

                      Where 'linksTpl' is the name of a chunk you will create in the next step.

                      Create the chunk 'linksTpl' containing something like this:
                      <ul>
                      <li><a title="Return to Website" href="[+back+]">Return to Website</a></li>
                      <li><a title="Continue to [+link+]" href="[+link+]">Continue to [+link+]</a></li>
                      </ul>
                      

                      Note- you can change the markup to whatever you need, just note the placeholders [+back+] (previous page) and [+link+] (external link).


                      plugin.exthref.php
                      Create a new plugin called 'extHref' and paste the contents of the file provided.

                      Scroll down to...
                      /* *** DISCLAIMER PAGE ID *************** */
                      $outbound = '1';
                      

                      ...and change '1' to the id of the disclaimer page containing the extHref snippet call.

                      If you need to add more link schemes, add them here:
                      /* *** EXTERNAL LINK SCHEMES ************ */
                      $schemes  = 'http,https,ftp,file,mailto';
                      


                      Before saving the plugin, click the System Events tab and check the box next to 'OnWebPagePrerender'.

                      And... that's it. Hope it makes sense and let me know if you have any issues.

                      Edit - download links were broken. I've re-uploaded the files, but can't remove the original links. Use the bottom two. [ed. note: okyanet last edited this post 10 years, 9 months ago.]