Code to disable Print and Save As

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baranitharan
    New Member
    • Jul 2006
    • 3

    Code to disable Print and Save As

    i need a code to disable user print and save as.if there is any javascript plz help me.last 1 month i need this code.the end user never save my pages and print my pages including text image
  • baranitharan
    New Member
    • Jul 2006
    • 3

    #2
    i need disable save as javascript

    Comment

    • sashi
      Recognized Expert Top Contributor
      • Jun 2006
      • 1749

      #3
      Hi Baranitharan,

      i have seen right click disable kind of codes around.. if you need a faster solution, you try looking in Google.com.. or else you can post your code segment on your next post and we will help you to validate your code.. take care..

      Comment

      • sashi
        Recognized Expert Top Contributor
        • Jun 2006
        • 1749

        #4
        Hi Baranitharan,

        check out the below code.. hope it helps you to get started with.. good luck my fren.. :)

        no right click for images..
        Code:
        <script language="JavaScript"> 
        <!--
        function noway(go) { if 
        (document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers) 
        { if (go.which == 3) { alert(popup); return false; } } } if (document.layers) 
        { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; 
        // --> 
        </script>
        no right click for source code..
        Code:
        <script language="JavaScript1.1"> 
        <!--
        var debug = true; function 
        right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which 
        == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' 
        && (event.button == 2 || event.button == 3)) { alert('This Page is fully 
        protected!'); return false; } return true; } document.onmousedown=right; if (document.layers) 
        window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right; 
        //-->
        </script>
        Disable Copy and Paste.
        Add the following html code to your BODY tag:
        Here is how your BODY tag may look once implimented:
        Code:
        <body bgcolor="#FFFFFF" ondragstart="return false" onselectstart="return false">
        Code:
        ondragstart="return false" onselectstart="return false"
        Last edited by sashi; Jul 17 '06, 04:18 PM.

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          baranitharan - I do not believe there is anyway to do what you want, File -> Save As and File -> Print are functions of the browser that you have no control over as they are not part of any web standard (i.e. HTML, Javascript, CSS etc). They are things that the browser designers put in because they thought they might be useful.

          sashi - the things you suggest are worst than useless IMO because they are not deterant to someone who knows what they are doing, all the do is make a site a little more irritating to use.


          If you are trying to prevent someone copying something you are publishing on the web then there is only 1 answer, don't publish it. Remember just by displaying it in there browser most people already have a copy of you item in there browser cache which is easy enough to access.

          Comment

          • baranitharan
            New Member
            • Jul 2006
            • 3

            #6
            thanks sashi. i am try you sample code...

            Originally posted by sashi
            Hi Baranitharan,

            check out the below code.. hope it helps you to get started with.. good luck my fren.. :)

            no right click for images..
            Code:
            <script language="JavaScript"> 
            <!--
            function noway(go) { if 
            (document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers) 
            { if (go.which == 3) { alert(popup); return false; } } } if (document.layers) 
            { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; 
            // --> 
            </script>
            no right click for source code..
            Code:
            <script language="JavaScript1.1"> 
            <!--
            var debug = true; function 
            right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which 
            == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' 
            && (event.button == 2 || event.button == 3)) { alert('This Page is fully 
            protected!'); return false; } return true; } document.onmousedown=right; if (document.layers) 
            window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right; 
            //-->
            </script>
            Disable Copy and Paste.
            Add the following html code to your BODY tag:
            Here is how your BODY tag may look once implimented:
            Code:
            <body bgcolor="#FFFFFF" ondragstart="return false" onselectstart="return false">
            Code:
            ondragstart="return false" onselectstart="return false"

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Welcome back, baranitharan. Whoa! 15 months after your original post!
              Originally posted by baranitharan
              thanks sashi. i am try you sample code...
              Listen to the advice from Banfa. JavaScript cannot disable these things. What you should consider is why you want to do this in the first place. If it's to protect images, just watermark them. Everything appears in the cache anyway, so disabling Save As has no effect on someone that is determined enough.

              Comment

              • AKS009
                New Member
                • Mar 2010
                • 4

                #8
                How to close open/save/cancel dialog box in IE 8 when user click on some button.

                please sugest its urgent.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  So you have a dialog open and you want to close it by clicking a button? or did you want something else?

                  Comment

                  • AKS009
                    New Member
                    • Mar 2010
                    • 4

                    #10
                    i need to bypass that open /save/cancel when i will click to open pdf in my web application how can i do that using some code or somewhere else./

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      If it's a browser functionality, you'll have to check the browser settings.

                      Do you want the PDF file to display in the browser without a dialog box or do you want to force a download?

                      Comment

                      • AKS009
                        New Member
                        • Mar 2010
                        • 4

                        #12
                        basically i have an application which will generate a consolidate pdf for all the user information at last page when user click on a button, i m calling window.open method to open that pdf in a new window,

                        it is working fine in IE 6 and IE 7

                        but in iE 8 its is opening addition popup that is open/save/cancel ,i want to avoid that using some code not using browser setting.

                        Comment

                        • gits
                          Recognized Expert Moderator Expert
                          • May 2007
                          • 5390

                          #13
                          you might try to add a Content Disposition header with inline and filename before sending the pdf from the server ...

                          kind regards

                          Comment

                          • AKS009
                            New Member
                            • Mar 2010
                            • 4

                            #14
                            can u just tell me where i need to put this code.. in java file or in JSP...

                            Comment

                            • gits
                              Recognized Expert Moderator Expert
                              • May 2007
                              • 5390

                              #15
                              you will probably have a line where the pdf is send/printed in your code? probably it will be located in a jsp-page? ...

                              Comment

                              Working...