Faqts : Computers : Programming : Languages : JavaScript

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

75 of 115 people (65%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How do I trap Right Click "Save Target As" ?
can i prevent SaveAs function of browsers
How can we disable the "File", "SaveAs" menu item in NN/IE?
how to disable "save" menu item of "file" menu option of the browser
What do I name these files and where do I put them?

Jul 25th, 2009 14:52
forum net tr, ha mo, Juergen Thelen, David H, Gerald Kilpatrick,


In my opinion this is wasted effort David, because experienced 
individuals are always able to get almost all of your web contents if 
they want (including documents, images, framesets, css and js files, 
and so on), no matter what you try...
But you asked for it, so here we go... :O)
Your question was about "Save target as", so you want to trap (linked) 
images, I guess. Below is a snippet able to do that for IE5 and NN4:
--- snip ---
<html>
<head>
<title>FAQTS - Juergen Thelen - Trap Save Target as (IE5/NN4)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#Blk1 { position: absolute; top: 10; left: 10 }
</style>
<script language="JavaScript1.2">
<!--
function TrapRight(e)
{
  if (e.which == 3) return false;
}
function Init()
{
  if (document.layers)
  {
    document.layers.Blk1.captureEvents(Event.MOUSEDOWN);
    document.layers.Blk1.onmousedown = TrapRight;
  }
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" onLoad="Init()">
<div id="Blk1"> <a href="dummy.htm"><img src="whatever.gif" width="20" 
height="20" border="0" oncontextmenu="window.focus(); return 
false"></a> 
</div>
</body>
</html>
--- snap ---
IE5 has an oncontextmenu event for almost any object type. All you need 
to do is to let the objects oncontextmenu event handler return false.
Note: window.focus() was only used in the above snippet to immediately 
blur the ugly focus rectangle IE usually shows when you click on a 
link, or linked image...
For NN4 I used a surrounding CSSP block element (a <DIV> named Blk1) to 
trap the right click event (never tried other solutions). Just tell NN4 
that you want to captureEvents(Event.MOUSEDOWN) for this block and 
setup an appropriate mousedown event handler like TrapRight(e) above.
To find out which mouse button the user clicked on the block just check 
the e.which event property TrapRight(e) receives from NN4 (e.which==3 
will be right click, e.which==1 will be left click).
A different way to achieve your goal would be to setup a complete fake 
context menu. This will be lots and lots of work, but if you don't mind 
this, have a look at
http://www.faqts.com/knowledge-base/view.phtml/aid/992/fid/126/lang/en
where you'll find at least the basics on how to setup your own context 
menu.
Hth, Juergen
full forum http://www.forumnettr.com/forum/ 
firmalar sirketler rehberi http://www.sirketfirmarehberi.com/ firma
sirket rehberi adres telefon bilgileri
secilmis youtube videolari http://www.youtubevideolari.net/ youtube videos
online video izle tr tube http://www.videotrtube.com/ komik videolar 
kaza videolarý çizgi film izle  http://www.komikturk.com/  kamera þakasý
videolarý  video klip izle  maç videolarý amatör video izle 
full program full oyun http://www.forumnettr.com/