473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Disabling the right click function in the Popped up window!

Hi,

I used a short code to pop up a thumbnail in a new window for a gallery view. The problem is I would like to disable the right click function on the popped up / new window. How can I do this?

This is the code i used to pop up the window:

<a href="#"><img src="sml/17.jpg" alt="Garden!" style="" onclick="javascript:window.open('lrg/17.jpg','new','width=850,height=650,resizeable=no, directories=no,toolbar=no,scrollbars=yes,left=12,t op=0');" width="72" height="71" border="0" /></a>

Thank you!
Mar 26 '07 #1
2 2046
acoder
16,027 Expert Mod 8TB
Welcome to TSDN.

I assume you know how to disable right-click, but need to access the new window. Put your code into a function and call that in the onclick of the link. When calling window.open, keep a ref. to the window:
Expand|Select|Wrap|Line Numbers
  1. var newWin = window.open(...);
then you can newWin to access the new window.

There are lots of scripts that let you disable right-click. Find them using a simple Google search. However, anyone determined enough will easily be able to bypass this 'security' measure.
Mar 27 '07 #2
hey try this

'Create a new page where the image will be placed. And popup this as the new window. Add this code in your script section of the popup page

Expand|Select|Wrap|Line Numbers
  1. function disable_right_click(e)
  2. {
  3.     var browser = navigator.appName.substring ( 0, 9 );
  4.     var event_number = 0;
  5.     if (browser=="Microsoft")
  6.         event_number = event.button;
  7.     else if (browser=="Netscape")
  8.         event_number = e.which;
  9.  
  10.     if ( event_number==2 || event_number==3 )
  11.         {
  12.         alert ("© ABC Co.Ltd. All rights reserved");
  13.         return (false);
  14.         }
  15.  
  16.     return (true);
  17. }
  18.  
  19. function check_mousekey ()
  20. {
  21.     var mouse_key = 93;
  22.     var keycode = event.keyCode;
  23.  
  24.     if ( keycode == mouse_key )
  25.         alert ( "© ABC Co.Ltd. All rights reserved" );
  26. }
  27.  
  28. function trap_page_mouse_key_events ()
  29. {
  30.     var browser = navigator.appName.substring ( 00, 9 );
  31.  
  32.     document.onmousedown = disable_right_click;
  33.  
  34.     if ( browser == "Microsoft" )
  35.         document.onkeydown = check_mousekey;
  36.     else if ( browser == "Netscape" )
  37.         document.captureEvents( Event.MOUSEDOWN );
  38. }
  39.  
  40. window.onload = trap_page_mouse_key_events;
Jul 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to...
20
by: dukeleto | last post by:
I know this is an annoying thing on some sites. I have set some images in an online gallery to have their own java po up window that is set to be the same size as the image. I would like to...
7
by: Robert | last post by:
Can I programmatically disable the right click context menu?
13
by: lightzizo | last post by:
All, How can I disable or remove the close button in the screen. thanks
12
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation...
3
by: surya52 | last post by:
I want to disable right click in my application.Here are my requirements. 1. I don't what to turn off shift click for the page. I want to turn it off for specific links. 2. I want shift-click to...
6
by: emmajoh | last post by:
Hi I'm trying to disable IE contextmenu (on a right click) as I want to create my own. The problem is that since I've installed the latest version of the google desktop, the script doesn't...
5
by: hp_1981 | last post by:
Hi Is there anyway avoiding users to save my web pages? this idea came to my mind when I tried to save a web page, but in the middle of saving progress something like the following error...
5
by: TC | last post by:
I don't use the Form Designer. Is there any way to disable it completely? I find it annoying that every time I create a new form, or double-click on an existing one, Visual Studio uses the Designer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.