如果html页面没有';如果没有特殊链接,请使用Javascript发出警报
javascript函数必须搜索网页(html正文)中的特殊链接(版权URL)。如果html页面没有';如果没有特殊链接,请使用Javascript发出警报,javascript,html,web,Javascript,Html,Web,javascript函数必须搜索网页(html正文)中的特殊链接(版权URL)。 如果找不到特殊的URL,则必须发出警报 JavaScript文件示例: if () { //If function find the copyright links, then null - don't make anything } else //If function doesn't find copyright links, then give an alert alert("Please protect
如果找不到特殊的URL,则必须发出警报 JavaScript文件示例:
if () {
//If function find the copyright links, then null - don't make anything
}
else
//If function doesn't find copyright links, then give an alert
alert("Please protect original copyright links.")
<html>
<head>
<script type='text/javascript' src='http:// ... file.js'></script>
</head>
<body>
<!-- Start Copyrigt Area -->
<div id="footer">
<a href="http://example1.com">example1.com</a>
<a href="http://example2.com">example2.com</a>
</div>
<!-- End Copyrigt Area -->
</body>
</html>
html页面示例:
if () {
//If function find the copyright links, then null - don't make anything
}
else
//If function doesn't find copyright links, then give an alert
alert("Please protect original copyright links.")
<html>
<head>
<script type='text/javascript' src='http:// ... file.js'></script>
</head>
<body>
<!-- Start Copyrigt Area -->
<div id="footer">
<a href="http://example1.com">example1.com</a>
<a href="http://example2.com">example2.com</a>
</div>
<!-- End Copyrigt Area -->
</body>
</html>
为什么? 我为特别的博客社区网站制作了一些主题。有时候,我们的 主题用户删除或更改页脚区域中的版权链接 博客社区网站不支持任何动态内容,如php, 我们只能在一个页面中使用html和一些特殊的内容标签 另一方面,这个网站不允许JS托管等等,所以,JS 由第三方托管提供商提供的文件 我不想加密代码。所以我想我们用一个 JavaScript函数。如果我们的链接被删除或更改,那么用户必须 得到警报 也许,一些主题用户会找到这些javascript函数并删除它们 然后重新托管代码。但我想他们中的大多数人不会 什么都行
这取决于您如何编写html。假设页脚元素始终存在:
if (document.getElementById('footer').childNodes.length == 0) {
//If function find the copyright links, then null - don't make anything
}
else
//If function doesn't find copyright links, then give an alert
alert("Please protect original copyright links.")
但请记住,这只是计算你放进去的东西
如果您的页脚不存在,如果您没有输入版权,请参阅peehaa的评论
不过,值得注意的是,看起来您只是引用了版权区域中的链接。比如说-我理解这项措施在安全方面没有任何作用,但如果你在意,这里有权利所有者的链接。如果这是真的,那就好了。干得好。如果你真的想要安全保护页面内容的版权,这不会保护任何东西。拖网搜索DOM不会阻止他们将CSS编辑为
display:none代码>悄悄地点击一些URL,这样你就可以联系那些人了。删除警报对他们来说是微不足道的,但许多人可能不会监视网络请求。if(document.getElementById('footer')==null){alert('this“protection”是徒劳的”);}
如果他们可以删除脚注,他们还可以删除您的Javascript代码。这与想要禁用源代码查看的人没有什么不同,右键点击,等等。总会有办法解决的。不要浪费你的时间。更新清除了什么吗?我不知道如何使它更清晰。这不是我最喜欢的解决方案,但非常感谢你的帮助。我也不知道,但很难一眼就知道这个函数的目标。