Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable the browser's print button

Status
Not open for further replies.

desiana

Programmer
Oct 31, 2001
23
0
0
MY
I am currently doing a program using JSP.In my program I have a print button
which does a function other that printing. That is why I want to restrict
users from clicking on the browser print button. I have thought of three
possible things that I can implement, i.e :
1. Disable the browser's tool bar
2. Keep track when users click the print button in the tool bar.
3. Pop up another window without the tool bar.
But the poblem is I don't have any idea of how to do those things.
Can you help me on this ?? Do you think those I mentioned are possible
to be done ? Any idea on Java Script command to do any of those three mentioned before ? If yes, then how to do that ? Thanks
 
Desiana,

First, answers to your questions.

1. Disable the browser's tool bar
Nope. Unless you hack your way through browser security

2. Keep track when users click the print button in the tool bar.
Not sure what you mean by that, but I'm not aware of any methods that will tell you when a user clicks on the browser print button.

3. Pop up another window without the tool bar.
This is about the only other option you have. Have your home page with maybe just a logo or something that says "Click Here To Enter". Then launch a new window excluding the tool bar, menu bar, etc...

Here's how you would do that.
Code:
<html>
<head>
<script Language=&quot;JavaScript&quot;.
<!--
var myWin
function openApp() {
  var winParms = 
&quot;width=500,height=400,shortcuts=no,toolbar=no,location=
no,status=no,directories=no,resizable=yes,copyhistory=no,men
ubar=no,scrollbars=yes,top=10,left=10&quot;
  if(myWin && !myWin.closed) {
    myWin.close()
  }
  myWin = window.open(&quot;somepage.htm&quot;,&quot;win1&quot;,winParms)
}
//-->
</script>
</head>
<body>
<a href=&quot;javascript:openApp();&quot;>Click Here To Enter</a>
</body>
</html>
That's a basic sample that shows you all of the settings you can apply to the new window. There's virtually a hundred different ways you can do this. I see alot of developers pass parameters in the function call, like this..
Code:
<a href=&quot;javascript:openApp('mypage.htm',500,400);&quot;>Click Here To Enter</a>
Then in the function, they pull those parameters to set the window size and load the page that's defined there.

Anyways, this should get you started.

Well, gotta go. Trick or Treaters knockin at the door !!

ToddWW
 
Thanks for your reply. Another question I want to ask you is, how to pass any data from another normal browser's window to this pop up window ? Because in my system, users need to log in, then I need to get those usernames and passwords to be used in the next pages.
 
Are you sure ?? If you use a relative path when you call the window.open() method, the visitor should still be authenticated on the site, even if you do open a new window. Have you tested it.

I'm assuming you're talking about Windows authentication..

ToddWW
 
What I want to do is : when user click a button, a pop up window will be displayed and the problem is how to pass values from the main window (the window in which the button is located) to the pop up window ? Usually, I use request.getParameter() to get values from another window, but it didn't work for pop up window. Thanks for your help.
 
I've lost you there because I'm not familiar with the request.getParameter() function. You might want to post a new thread related to that subject.

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top