ユーザーが自分のサイトの外部リンク (特定の ID またはクラスのいずれかで識別される) をクリックすると、10 秒のカウンターでポップアップが表示され、10 秒後にポップアップが閉じ、ユーザーができるようになります。外部 URL にアクセスします。これはどのように行うことができますか?以下のような警告を表示できますが、タイムアウトを追加する方法がわかりません。また、これはボックスであり、カウンターが停止するまでユーザーが表示できるものをconfirm
追加できるポップアップではありません。div
$(document).ready(function(){
var root = new RegExp(location.host);
$('a').each(function(){
if(root.test($(this).attr('href'))){
$(this).addClass('local');
}
else{
// a link that does not contain the current host
var url = $(this).attr('href');
if(url.length > 1)
{
$(this).addClass('external');
}
}
});
$('a.external').live('click', function(e){
e.preventDefault();
var answer = confirm("You are about to leave the website and view the content of an external website. We cannot be held responsible for the content of external websites.");
if (answer){
window.location = $(this).attr('href');
}
});
});
PS: 無料のプラグインはありますか?