Forum Moderators: open
I have question regarding the above subject.
Basically, if a user if presented with a simple
<a href=""></a> based link, the user can either click on it to open it or right click on the link and open that in a new window.
My question is how can I stop the user from right clicking on the link and opening it (I know I can disable right clicks...but that will be my last resort).
If I cannot stop it, is there a way for me to track that the user opened a link using right click and then display, a warning msg on the new window...?
I have seen the above warning behaviour on an online banking website which was HTTPS enabled...not sure if we need HTTPS for this behaviour or can JS work here. Tried to look at their JS code but the whole thing seems to be hidden...:(
Thanks for any inputs....!
Bhushan.
<script type="text/javascript">
window.onload = Init;function Init() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
anchor.attachEvent("oncontextmenu", FollowLink);
}
}function FollowLink() {
document.location.href = event.srcElement.href;
return false;
}
</script><p><a href="http://www.google.com/">Google</a></p>
<p><a href="http://www.yahoo.com/">Yahoo</a></p>
Thnx for the response....this looks like a good process. I am gonna try it out right now...!
Let me explain what our problem is:-
We are using session based objects which are shared when the user moves from one IE window to the other in the same "IE instance"...but if the user opens a new IE window from the existing IE window/instance, the session now gets shared between two "separate" windows(which spawned from the same instance) that corrupts session data....
So another issue we have is: Is there a way for us to trap the event when the user opens a new window through menu:
File --> New --> Window....?
Currently I have been able to trap the (cntrl + N) route, and display a warning message but still trying to figure out way to trap file new window route. above...
Thnx for all ur help...!