How do I add a upper frame on all the outgoing links?

Discussion in 'HTML & Website Design' started by Teunel, Sep 26, 2007.

  1. #1
    Hi,

    I'm running a pretty succesfull forum, but lots of people are placing links to other websites.

    I've seen a few websites, where you can click on a link, but it has a little frame on the top, where it says something like: You're visiting a website that's not related with mywebsite.com

    How can I do this? :) Thanks!
     
    Teunel, Sep 26, 2007 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to change the links to a page on your site with their site loading in a frame/ iframe though they can use scripts to break the site out of it if they want which you cannot prevent
     
    AstarothSolutions, Sep 26, 2007 IP
  3. Teunel

    Teunel Guest

    Messages:
    246
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, I believe this can be done automatically, because I've seen this on other forums, and I doubt they've edited all outgoing links..
     
    Teunel, Sep 26, 2007 IP
  4. Bishop81

    Bishop81 Peon

    Messages:
    757
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I can do this for you... Give me a couple days then PM me to see if I'm still working on it and haven't forgotten.

    If you want to go at it yourself, here's the plan...

    Use this javascript to intercept the outgoing link:
    
    if (window.captureEvents){
    	window.captureEvents(Event.CLICK);
    	window.onclick=sourceCheck;
      }
      else{
    	document.onclick=sourceCheck;
    }
    
    function sourceCheck(e){
      var el=(typeof event!=='undefined')? event.srcElement : e.target;
      if (el.tagName =="A") {
    	clickedlink=el.href;
    	alert(clickedlink);
    	return false;
      }
    }
    
    Code (markup):
    Then create a function to redirect the user to another php page...

    Replace the alert(clickedlink) with location.href="mynewpage.php?link=" + clickedlink; .

    On the php page, just get the link from the url, using $_GET["link"];.

    On the php page, have an iframe that is the width of the page, and place it a little bit down the page. Place whatever you want in the top there, even advertising.

    Hope this isn't too confusing. I'll work on something too and try to get it to you shortly.
     
    Bishop81, Sep 28, 2007 IP
  5. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #5
    If you're using VBulletin, look for a mod at vbulletin.org
     
    nabil_kadimi, Sep 28, 2007 IP
  6. Bishop81

    Bishop81 Peon

    Messages:
    757
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I am SO SORRY that it took so long, there's no excuse for it. I just got caught up with other stuff and forgot.

    Here is a location to see a demo: DEMO

    And here is the download of the 3 files involved in the demo: DEMO

    All you have to do is add this to your existing header code:
    <script type="text/javascript" src="newwindow.js"></script>
    Code (markup):
    If you have any questions, just ask. This is available for anybody who wants it, so feel free to download and use it. If it helps you, then some rep would be nice.
     
    Bishop81, Oct 21, 2007 IP
    joshbond likes this.
  7. Bishop81

    Bishop81 Peon

    Messages:
    757
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Bishop81, Oct 23, 2007 IP
    Teunel likes this.
  8. Teunel

    Teunel Guest

    Messages:
    246
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thank you very much! +rep! :D
     
    Teunel, Oct 23, 2007 IP