オンラインバンキングクライアントのこの問題を解決しました。FDIC は、ユーザーがサード パーティのサイトに移動するたびに、確認の "スピードバンプ" を必要とします。目立たないようにして、移動できないようにしたかったのです。
IE、Firefox、Chrome、および Android でこれをテストしました。クリック、右クリック、中クリック、Shift クリック、Shift F10、Enter、ロングタップ、すべて (Firefox は難しい)。スピードバンプが発生するか、空白のタブが表示されますが、それを回避することはできません.
document.ready = function() {
var handleSpeedBump = function(e) {
e.preventDefault();
var href = this.getAttribute("data-href");
var sure = confirm("Are you sure you want to navigate to " + href + "? This is a third party site and not owned by this institution.");
if (!sure) return;
document.location = href;
}
$("a.speedbump")
.click(handleSpeedBump)
.bind("contextmenu", handleSpeedBump)
.dblclick(handleSpeedBump)
.each(function() {
var href = this.href;
this.setAttribute("data-href", href);
this.href = "javascript:void('Navigate to " + href.replace("'", "") + "')";
})
}
これを機能させるには、通常どおりにリンクを作成し、そのクラスに「スピードバンプ」を追加するだけです。
<A href="www.thirdpartysite.com" class="speedbump">Here is the link!</A>