我已经在博客上看到了模板所有者页面的页脚链接。如果我试图通过编辑HTML内容来删除或隐藏链接。这是不可能的,该网站将被重新定向到他们的网站。我知道这是由javascript完成的。有没有人能教我怎么做?
<div class="copyright-area">Template by <a href="http://www.example.com/" id="mycontent" >some name</a></div>上面的代码就是一个例子。如果我在上面的代码中添加任何修改,它将重定向到他们的网站。有没有人能教我怎么用javascript来做这个?
发布于 2020-08-21 20:15:46
试试这个:
$(document).ready(function() {
// Check if href is changed
if ($("#mycontent").attr("href") != "https://www.example.com") {
window.location.href = "https://www.example.com"; // Redirect destination link
};
// Check if tag is hidden
if ($("#mycontent").css('display') == 'none' || $("#mycontent").css("visibility") == "hidden"){
window.location.href = "https://www.example.com"; // Redirect destination link
}
});<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href='https://www.example.com' id='mycontent'>Credit Link</a>
如果#mycontent的href已更改、未显示或其可见性设置为隐藏,您将被重定向至目标链接。
https://stackoverflow.com/questions/63509426
复制相似问题