如何在页脚中添加类似于免费博客模板的链接

问题描述

我在Blogger博客上看到了指向模板所有者页面的页脚链接。而且,如果我尝试通过编辑HTML内容来删除或隐藏链接。这是不可能的,该网站将被重定向到他们的网站。我知道这是通过javascript完成的。有人可以帮我怎么做吗?

<div class="copyright-area">Template by <a href="http://www.example.com/" id="mycontent" >some name</a></div>

上面的代码是一个示例。并且,如果我在上述代码中添加了任何修改,它将重定向到他们的网站。谁能告诉我如何使用javascript吗?

解决方法

尝试一下:

$(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的{​​{1}}被更改,未显示或可见性设置为隐藏,您将被重定向到目标链接。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...