本文介绍了如果html页面没有特殊的链接,那么用Javascript提醒一下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 javascript函数必须搜索网页(html正文)中的特殊链接(版权网址)。 如果没有找到特殊的网址,那么必须提醒。 JavaScript文件示例: if(){ //如果函数找到版权链接,然后null - 不做任何东西} else //如果函数找不到版权链接,则发出警报警报(请保护原始版权链接。 ) html页面示例: < html> < head> < script type ='text / javascript'src ='http:// ... file.js'>< / script> < / head> < body> < div id =footer> < a href =http://example1.com> example1.com< / a> < a href =http://example2.com> example2.com< / a> < / div> <! - 完稿件区 - > < / body> < / html> 为什么? 我为特殊博客社区网站制作了一些主题。有时,我们的主题用户删除或更改我们在页脚区域的版权链接。 博客社区网站不支持任何动态内容,如php,我们只能在一个页面中使用html和一些特殊的内容标签。 另一方面,这个网站不允许JS托管等。 ,JS 文件由第三方托管服务提供商提供。 我不想加密代码。所以我认为我们使用 JavaScript函数检查链接。如果我们的链接被删除或更改,那么用户必须才能获得提醒。也许,一些主题用户会发现这些javascript函数并删除他们和重新托管代码。但我认为他们中的大多数人不会有任何东西。 解决方案关于你如何写你的HTML。假设页脚元素总是存在: if(document.getElementById('footer')。childNodes.length == 0) { //如果函数找到版权链接,则为null - 不要生成任何内容} else //如果函数找不到版权链接,然后发出警报警报(请保护原始版权链接。) 但请记住,这只是计算你在那里放的东西。 如果你没有放置版权,你的页脚就不存在了,那么请看peehaa的评论。 $ b 然而,应该注意的是,它好像只是引用版权区域中的链接。就像说 - 我明白这项措施在安全方面没有做任何事情,但如果你关心,这里有权利所有者的链接。如果这是真的,那么很好。干得好。如果您确实希望安全地对页面上的内容进行版权保护,则这不会保护任何内容。 A javascript function must search the special links (copyright urls) in a web page (html body).If it doesn't find the special urls, then must give an alert.Example of JavaScript file:if () {//If function find the copyright links, then null - don't make anything}else//If function doesn't find copyright links, then give an alertalert("Please protect original copyright links.")Example of html page:<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> WHY? I made some themes for special blog community site. Sometimes, our theme users remove or change our copyright links in the footer area. The blog community site doesn't support any dynamic content like php, we can use only html and some special content tags in a one page. On the other side, this site doesn't allow JS hosting, etc. So, JS files provided by third party hosting providers. I don't want encrypt the code. So I think we check the links with a JavaScript function. If our links removed or changed, then users must get an alert. Maybe, some theme users find these javascript function and removes them and re-host the codes. But I think most of them will can not anything. 解决方案 It depends on how you write your html. Assuming the footer element is always there: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 alertalert("Please protect original copyright links.")but remember, this just counts what you put in there.If your footer is absent if you did not put copyrights in, then see peehaa's comment.Should be good to note, however, that it looks like you're just referencing links in the copyright area. Like saying - I understand this measure does nothing in the way of security, but in case you care, here are links to the rights owners. If this is true, then goody. Here you go. If you actually want security in place to copyright the content on a page, this will not protect anything. 这篇关于如果html页面没有特殊的链接,那么用Javascript提醒一下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 13:29