您可以查找所有錨點元素並驗證具有該href的錨點是否存在或使用其他條件進行驗證。
var isMyLinkPresent = function() {
var anchors = document.getElementsByTagName('a');
for (i = 0; i < anchors.length; i++) {
if(anchors[i].attr('href') === "http://domain.com") {
return true;
}
};
return false;
}
//in case you want to notify you own server of the presence, this will send a request to your server for picking up which site actually has the link
(function() {
if (isMyLinkPresent()) {
var script = document.createElement('script');
script.attr('src', 'http://domain.com/tellmewhichsitehasit?site=' + window.location.host)
document.head.appenChild(script);
}
})();
另外,你可以把自己的JavaScript鏈接,但你必須有一些API的網站管理員將使用。在腳本的'src'屬性中,您可以添加參數,然後您可以在生成javascript時選擇它,或者通過查看src來解釋它。
該鏈接可以使用'display:none'來輕鬆隱藏。如果您確實需要「鏈接誘餌」,請考慮在代碼的活動部分附近添加一個小鏈接。如果有人喜歡你的功能,他們可能會訪問你的網站。 –