PDA

View Full Version : Protect opening in new window?


ljuba
01-26-2003, 03:15 PM
I need to protect visitor open some link in new window. I made protection (I have 2-3 ways to do this) in JS to protect right-click-mouse but somebody can keep Shift button and click with left-click-mouse and open it in new window. Can I protect page of that using JS? :confused:

Thanks,

Ljuba

scroots
01-26-2003, 03:25 PM
Protecting a page using JS may deter some people but not thouse who are determined. There are a varety of ways to counteract no right click scripts (left handed people with mouse buttons reversed hate right click scripts). Also poup windows can be counteracted by going view source and getting the address of the popup window.

After all what have you to protect? your source code? 90% of the source code on the web is the same. Unless you have something specific to protect which is highly valuble you will need to find somethnig better than javascript. As all ways to protect stuff using javascript can be by passed.

scroots

ljuba
01-26-2003, 03:33 PM
Hello,

thanks for answer ...

I don't want to protect my source code using JS ... All site is in ASP and I just want to keep control on opening windows ... For example if visitor click on some menu item I want to open that file where I want because I am trying to make some comparation ... and if visitor open link in new window - it will present nothing ... Thant's why ...

And if somebody really want to find out name of file and all Request.QueryString parameters he can find it using View Source ...

PS: I am new on this forum ... I am not new in WEB Development!

Thanks again and bye,

Ljuba

scroots
01-26-2003, 03:38 PM
sorry its easy to miss read questions when i`m worn out.

could you not try
<A HREF="#" onClick="dothis();dothat();">MY LINK</A>

scroots

ljuba
01-26-2003, 03:45 PM
Hi,

I made something like that and made some function ... some alert message ... And if I keep Shift and klik on link I get apert and when I press OK button I get new window with same URL + #

That is not solution ...

I need some event handler which will ignore Shift button ...

Bye,

LJUBA

scroots
01-26-2003, 03:50 PM
based on http://www.a1ien51.8k.com/scripts/key.htm you could use

<script>
function handleKeyPress(evt) {
var nbr, chr;
if (window.Event) nbr = evt.which;
else nbr = event.keyCode;
if(nbr==16||){//place key codes here
return false;}
}
document.onkeydown= handleKeyPress
</script>
or something similair.
scroots