Forum Moderators: open
What you could do is to alter your links, if any of the links are pointing to an external page, change it (on the server-side preferably) in a way, that it goes to a sort of jump page first, or it involves a javascript function. From then on, you can do whatever you want with links pointing to external pages (either with javascript, or with a sort of jump page).
Here's another thought. I notice that all the pages in any particular web site always have the domain name in them for that site. For example for the home page www.mywebsite.com, then for pages 2 and 3 www.mywebsite.com/page2 and www.mywebsite.com/page3. Can I somehow key on that.
In a fact, not. An URL van be absolute or relative. A relative url does not contain the whole address, it might not have the domain name included for example, or part of the path is not defined as well, in these cases we talk about relative urls. An absolute url always starts with the protocol definition, for example "http", followed by the "://" separator.
In the case of a relative url, the browser resolves it into an absolute url, based on the location of the current page, in the following way (suppose the browser has the http://www.example.com/foo/bar/index.html loaded):
The top four ones are relative urls, while the next two ones are absolute urls, and the last one is also considered to be relative url by the browser, because it does not include the http:// protocol definition, and even the path information is not present, so it resolves to a very funny url.
So, to determine whether an url is external or internal, you need to first examine that it starts with [,...] and that the hostname (www.example.com) is not from your website. if the above conditions are met, the link is pointing to an external website.
How you can check all your links? Using JavaScript you can make a function, and instead of using <a href="http://www.example.com"> do <a href="javascript:jumpTo('http://www.example.com');">, and within the jumpTo function you can check the url, if it's an internal one, jump to that url, when external, display your message (some way).
You can do this on the server side as well (works better, even with javascript disabled - some users tend to disable that), then look around in the documentation in the programming language you are using (php, asp, etc).
There's a different approach using JavaScript, but it is more difficult. After the page loads, you run a javascript code, which 'scans' your html page, and alters the <a> elements as necessary, but this requires fair knowledge of DOM and JavaScript.
The external destination page could be known after the visitor clicks on the link to it.