faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 11 people (55%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can I restrict a user from opening a new window through file-new-window?

Nov 2nd, 2005 09:06
Jason Benson, Bryan McGraw,


Short answer is that you cannot (and should not).

However there are a few ways that you can try however all can be 
repelled by the user.

In ASP / VBScript you could easily set a Session variable for a unique 
QueryString that would need to be present everytime the page is 
processed.

Example
<% 

If Request.QueryString("MyValue") <> Session("ValidWindow") Then
   Response.Write "Your Error Message Here
End If

Randomize   ' Initialize random-number generator.
MyValue = Int((10000 * Rnd) + 1)   ' Generate random value between 1 
and 10000
Session("ValidWindow")=MyValue 
%>

So every url you would have would have to append the "ValidWindow" 
Session to the QueryString.  This isn't difficult, however it is not 
full-proof and you should look into other ways to structure your 
application.

If you choose to use Javascript or client side VBScript to attempt to 
close any extra windows that the user creates, they will receive a 
warning and be able to keep the window open in almost all modern 
browsers.

Hope that helps
JB



© 1999-2004 Synop Pty Ltd