Web Analytics Made Easy -
StatCounter Restrict Printing and Text Copy - CodingForum


No announcement yet.

Restrict Printing and Text Copy

  • Filter
  • Time
  • Show
Clear All
new posts

  • Restrict Printing and Text Copy

    I am trying to accomplish two things and am pretty sure JavaScript is the tool to do it, but don't know how.

    1) I am trying to disable a page from being printed and
    2) I am trying to disable the ability to copy and paste text or images from the web page.

    I would appreciate any assistance that I could get with this task.

    Thank you in advance,
    Last edited by ExcelGuy; Sep 26, 2003, 08:35 AM.

  • #2
    Sorry, Javascript does not have this ability.


    • #3
      You can *try* this for IE:

      <body onbeforeprint="return false" onprint="return false" onbeforecopy="return false" oncopy="return false" onbeforecut="return false" oncut="return false">

      I personally wouldn't like a site preventing me from copying text or disabling my ability to print it.

      Of course, all that is needed is to disable Javascript to copy and print anyway.


      • #4
        I'm with JKD on this'un. I spend countless hours online every day, and well, after a while I need to 'keep my place' while reading. How do I do it? I highlight each word as I read it so eventually I've got a good half a page highlighted.

        Most 'copy prevention' methods disable highlighting, as well. And well, I don't like that.

        Not that you should ditch the idea just for me. Just saying, I'm sure I'm not the only one. Or maybe I'm a freak, and I am a freak, who knows.

        Jers-Web, Inc.
        Ever seen 49,825 Alert Boxes on one page? I have!


        • #5

          I am in agreement with you guys on it being annoying to not allow copying etc, but I am on a project where they are concerned about someone taking some published information, editing it, and then trying to come back and sue saying we gave them bad information.


          • #6
            If that is the case, Excel, then you need something much more robust, you need it to be bulletproof, not relying on browser or he said she said kind of stuff.

            You need to look into Version Control systems which allow you to show exactly what was on your site at any time in the past, when and if anything changed, and various other things. A lot of CMS suites are actually just Version Control programs (Interwoven the horrible being a prime example)
            Moderator, Perl/CGI Forum
            shadowstorm.net - subvert society


            • #7
              No Text Select

              Here is a no text select script:

              <script language="JavaScript1.2">

              //Disable select-text script (IE4+, NS6+)

              function disableselect(e){
              return false

              function reEnable(){
              return true

              //if IE4+
              document.onselectstart=new Function ("return false")

              //if NS6
              if (window.sidebar){

              And this is a No right Click script:

              <script language=JavaScript>

              //Disable right click script

              var message="";
              function clickIE() {if (document.all) {(message);return false;}}
              function clickNS(e) {if
              (document.layers||(document.getElementById&&!document.all)) {
              if (e.which==2||e.which==3) {(message);return false;}}}
              if (document.layers)

              document.oncontextmenu=new Function("return false")
              // -->

              try those out


              • #8
                Resistance is futile. Like Feyd says you will have to look into other options if your end goal is just to cover your butt. NO matter what you do to a page dispalyed in a brwoser there is always a way to get around it.

                Using JavaScript to "disable" certain functionality within a page can be circumvented in several ways.

                I can't wait untill the FAQ page is up and running.


                • #9

                  Thank you SteveKitz for the scripts. Again, I am in agreement with most of the comments about versioning and non-bulletproof systems. We are using Oracle Portal, which does allow for versioning, but I have spent too much time already trying to convince the high ups about the security they do not see.

                  Get this, this is a corporate intranet site, only accessable with a VPN or from on our network. The stores that have the ability to connect are using a machine we built which is locked down to the point that they cannot save information to thier hard drive, and temp directories are deleted when the computer is rebooted, so if a machine is stolen, nothing is saved. The do not have e-mail, they do not have a floppy drive, and yet, that is not secure enough. The information we are putting out, used to be sent to the stores on paper and kept in notebooks in the back room. Anyone could take it or copy it.

                  Anyway, not that anyone cares about all of this, I just appreciate the help and responses you guys gave.



                  • #10
                    I would like to be able to disable the print option, through anymeans necesarry, I'm developing an internal web-site, and some users may be able to view a document, but not have the print options. I've been going over this all day. Is there a way to cancel a print request in the onbeforeprint. I've tried everything posted here so far with no results.


                    • #11
                      Regarding your worry, that someone might modify the document - if I'm not mistaken all you need to do is save the document in UNmodified form - keep track of any changes by perhaps adding a datestamp to the filename.

                      A check of the last modified date of the document(s) in question would reveal whether the document was taken and modified at a later date - wouldn't it?
                      Former ASP Forum Moderator - I'm back!

                      If you can teach yourself how to learn, you can learn anything. ;)


                      • #12
                        Okay this is the best that I've come up with, and maybe it will help others even though it doesn't exactly pertain to Javascript. but with the link tag you can do this

                        <link rel=alternate media=print href="blank.htm">

                        Anytime someone wants to print it prints the blank.htm instead. I know this works in IE 6, don't know about N6


                        • #13
                          *sigh* - you can't stop people from printing/copying/viewing source code...

                          I could still save the page from my temporary internet files, and take out the code you posted above... and just take the text as is.

                          There isn't ANY way around that. Period. (Not if you want the page to display in a browser, at any rate...)
                          Former ASP Forum Moderator - I'm back!

                          If you can teach yourself how to learn, you can learn anything. ;)


                          • #14
                            Well the people that this is for aren't that computer literate, so hopefully if I diable right click and remove the menu bar, that they won't see those options. Thanks for all the help guys.


                            • #15
                              It can be accomplished...

                              Most of my users are in the illiterate category as well, but security is security, and underestimating your audience is not a good idea.

                              As far as what can and can't be done, it is possible to combine all of the security restrictions that have been posted here and encrypts the page as well. My web searches found a program called Web Protecter 2.0, at http://www.protecthtml.com/ that supposedly accomplishes exactly what I am looking for. I think it is only $50 but I am interested to know what it is doing to accomplish the goal. I think it is opening the page in some java or JavaScript window that encrypts it, but I am not sure. I will probably just get the program, but I am really intrigued as to how this is working.

                              Does anyone have experience with this program?