A few days ago, the boss asked the company to save and print some important documents (most of them PDF files. It is easy to enable this function. You can use a hyperlink to open it in IE. However, before opening it, ie will automatically pop up a dialog box that provides three operations: open, save, and cancel. Needless to say, this step allows users to save files. In fact, some people on the internet suggest using Servet to read files in the servlet, and then return only the content of the file to the user. In fact, this is exactly the same as hyperlink. Before the file is displayed, you can save the file. But a lot of people get a friend's webpage embedded prompt. Let me solve this problem.
1. Embedded pdf on the webpage
<Table border = "0"> <br/> <TD> <br/> <P style = "margin-top:-57px; margin-bottom: 0 "mce_style =" margin-top:-57px; margin-bottom: 0 "> <br/> <object classid =" CLSID: CA8A9780-280D-11CF-A24D-444553540000 "id =" pdf1 "width =" 730 "Height =" 606 "> <br/> <Param name =" _ version "value =" 327680 "> <br/> <Param name = "_ extentx" value = "19315"> <br/> <Param name = "_ extenty" value = "16034"> <br/> <Param name = "_ stockprops" value = "0"> <br/> <Param name = "src" value = "1.20."> <br/> </Object> <br/> </ TD> <br/> </tr> <br/> </table> <br/>
Stype = "margin-top:-57px" to hide the "print" and "Save as" buttons in PDF.
2. Right-click the disabled webpage
Because right-clicking a webpage can print a webpage, it is necessary to disable the webpage's right-clicking function.
<MCE: script language = "JavaScript"> <! -- </P> <p> If (window. event) <br/> document. captureevents (event. mouseup); </P> <p> function nocontextmenu () <br/>{< br/> event. cancelbubble = true <br/> event. returnvalue = false; </P> <p> return false; <br/>}</P> <p> function norightclick (E) <br/>{< br/> If (window. event) <br/>{< br/> If (E. which = 2 | E. which = 3) <br/> return false; <br/>}< br/> else <br/> If (event. button = 2 | event. button = 3) <br/>{< br/> event. cancelbubble = true <br/> event. returnvalue = false; <br/> return false; <br/>}</P> <p> document. oncontextmenu = nocontextmenu; // For ie5 + <br/> document. onmousedown = norightclick; // for all others <br/> // --> </MCE: SCRIPT> <br/>
3. the toolbar of the webpage must be hidden.
Because I used a hyperlink to open a new webpage to view the file, the toolbar = No
Function popup (mypage, myname) {<br/> winprops = 'height = 950, width = 1000, Left = 10, Top = 10, scrollbars = Yes, dependent = Yes, resizable = Yes, toolbar = No, status = No, directories = No, menubar = no'; <br/> win = Window. open (mypage, myname, winprops); <br/> If (parseint (navigator. appversion)> = 4) {win. window. focus () ;}< br/>}