Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
578 views
in Technique[技术] by (71.8m points)

If html page doesn't have the special links, then give an alert with Javascript

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 alert
alert("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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 alert
alert("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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...