• Protecting Your HTML Code With JavaScript

    Date: 2011.02.24 | Category: Scripts, WebDesign | Tags:

    We all know that source code theft is wrong and covered by copyright never the less some webmasters will inevitably try to steal the work that the honest ones amongst us create.

    Unfortunately, there is no sure fire way to stop people from stealing our HTML code but, we can make it hard for them.

    The following JavaScript coding, when placed in your <body> tag can make it harder for the opportunistic webmaster to steal your coding.

    Simply copy and paste everything below into your body tag and change the text in the var message=”” field.

    <!–Start Copy–>
    <SCRIPT language=”JavaScript”>
    <!–
    var message=”Copyright 2000 by Your Site. WARNING ! All content contained within this site is protected by copyright laws. Unauthorized use of our material is strictly prohibited.”;
    function click(e) {
    if (document.all) {
    if (event.button==2||event.button==3) {
    alert(message);
    return false;
    }
    }
    if (document.layers) {
    if (e.which == 3) {
    alert(message);
    return false;
    }
    }
    }
    if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=click;
    // –>
    </SCRIPT>
    <!–End Copy–>

    Whilst this is not a sure fire way to stop the occurrence of HTML theft as mentioned already it will deter those webmasters who perhaps were there for the simplistic reason of viewing your source code.

    Article written by Lee