- Create a middle page which get redirect url in query string and display message you are asking. Use javascript
window.location.href = <redirecturlfromquerystring>
Now coming to all your source links.
Option 1
If you can put a css class on all your external class. you can bind click event to all your external links
Sample html
<div id="commercial-container">
<a href="http://www.link1.com" class="external" target="_blank"> <img src="picture1.jpg" /> </a>
<a href="http://www.link2.com" class="external" target="_blank"> <img src="pciture2.jpg" /> </a>
<a href="http://www.link3.com" class="external" target="_blank"> <img src="picture3.jpg" /> </a>
<a href="http://www.link4.com" class="external" target="_blank"> <img src="picture4" /> </a>
</div>
<script>
$(".external").click(function(event) {
// redirect user to your middle page and pass url as query string paratmeter
window.location.href = "yourexternalpage.aspx?redirecturl=" + $(this).href() ;
});
Options 2 - if you can't add css class to all external links.
Sample html
<a href="yourwebsitedomain.com">staying in site</a>
<a href="two">going external</a>
<script>
var a = document.getElementsByTagName('a');
var b = a.length;
while(b--){
a[b].onclick = function(){
if(this.href.indexOf('yourwebsitedomain.com')<0){
// redirect user to your middle page and pass url as query string paratmeter
window.location.href = "yourexternalpage.aspx?redirecturl=" + $(this).href() ;
}
else{
window.location.href=$(this).href() ;
}
};
}
</script>
Server side
Just an high level idea...
- Create middle page which take querystring as redirect url.
on the code behind page load, read querystring redirect user using response.redirect.
All your hyperlink should have server side event which should trigger on click of link.
in your event, you can use below logic
if(domain of redirect url and current site is same){
redirect user to redirect url
}
else
{
redirect user to middle page and pass redirecturl as query string
}