Confirm Leave on External Links in Wordpress

后端 未结 2 2065
无人共我
无人共我 2020-12-12 04:49

Here\'s the situation:

  • This is a bank website, so when a user clicks an external link (perhaps to a Facebook page or a partner website), there needs to be a

2条回答
  •  误落风尘
    2020-12-12 05:48

    Here's one way you could do it (See JSFiddle):

    $("a").on("click", function() {
        if($(this).attr("href").indexOf("http://") == 0) {
            return confirm("Super long message");
        }
    });
    
    • This would only work for http:// and not https://, it also doesn't check whether the absolute link points to your current domain, but it gives you and idea of how to approach it.

提交回复
热议问题